:root {
  --brand-red: #8b1e3f;
  --brand-green: #0f6a5a;
  --brand-orange: #ef6a09;
  --bg: #f4f4f4;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}
* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #f7f7f7 0%, #f1f3f3 100%);
  color: var(--text);
}
a { color: inherit; }
.container { max-width: 1240px; margin: 0 auto; padding: 24px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  flex-wrap: wrap; margin-bottom: 24px;
}
.brand {
  background: linear-gradient(90deg, var(--brand-red) 0 50%, var(--brand-green) 50% 100%);
  color: white; padding: 16px 20px; border-radius: 18px; min-width: 340px;
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
}
.brand h1 { margin: 0 0 6px; font-size: 30px; }
.brand p { margin: 0; opacity: 0.96; }
.nav { display: flex; gap: 10px; flex-wrap: wrap; }
.nav a, .btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  padding: 10px 14px; border-radius: 12px; font-weight: 700;
}
.nav a { background: white; border: 1px solid var(--border); }
.nav a.active, .btn-primary { background: var(--brand-green); color: white; }
.btn-secondary { background: var(--brand-red); color: white; }
.btn-light { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #b42318; color: white; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--card); border-radius: 20px; box-shadow: 0 8px 24px rgba(0,0,0,.05);
  border-top: 5px solid var(--brand-green); padding: 20px;
}
.card.red { border-top-color: var(--brand-red); }
.card.orange { border-top-color: var(--brand-orange); }
.card h2, .card h3 { margin-top: 0; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; margin-top: 10px; }
.mt-8 { margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { text-align: left; color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; height: 34px;
  border-radius: 10px; border: 1px solid var(--brand-red); color: var(--brand-red); font-weight: 700;
}
.player-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.player-row:last-child { border-bottom: 0; }
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid #d1d5db; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice {
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
}
.warning {
  background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
}
.meta { color: var(--muted); font-size: 13px; line-height: 1.45; }
.list-item { border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; background: white; }
.sponsor-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #fff7f0 100%);
}
.sponsor-logo-wrap {
  background: #fff; border: 1px solid #fde3cf; border-radius: 16px; padding: 12px; flex: 0 0 auto;
}
.sponsor-logo-wrap.compact { max-width: 230px; }
.sponsor-logo { display: block; max-width: 320px; width: 100%; height: auto; }
.footer {
  margin-top: 28px; padding: 18px 0 8px; text-align: center; color: var(--muted); font-size: 14px;
}
.hero-note {
  background: linear-gradient(90deg, rgba(139,30,63,.08), rgba(15,106,90,.08));
  border: 1px solid rgba(15,106,90,.12); border-radius: 14px; padding: 14px 16px;
}
code { background: #f3f4f6; padding: 2px 6px; border-radius: 6px; }
@media (max-width: 700px) {
  .container { padding: 14px; }
  .brand { min-width: auto; width: 100%; }
  .sponsor-card { flex-direction: column; align-items: flex-start; }
  .sponsor-logo { max-width: 260px; }
  .actions { flex-direction: column; }
}


.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  font-size: 14px;
  color: #666;
}
.footer img {
  height: 14px;
  vertical-align: middle;
  margin-left: 6px;
}


.match-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
}
.match-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 170px;
  padding: 12px 18px;
  border-radius: 14px;
  background: #ffffff;
  color: #8B1E3F;
  border: 1px solid rgba(139, 30, 63, 0.22);
  font-weight: 700;
  text-decoration: none;
  box-shadow: none;
  transition: all .15s ease;
}
.match-tab:hover {
  background: #faf5f7;
  color: #8B1E3F;
  border-color: #8B1E3F;
}
.match-tab:visited {
  color: #8B1E3F;
}
.match-tab.active {
  background: #8B1E3F;
  color: #ffffff !important;
  border: 1px solid #8B1E3F;
}
.match-tab.active:visited {
  color: #ffffff !important;
}
.footer img {
  height: 14px;
  vertical-align: middle;
  margin-left: 6px;
}


#matches-tabs {
  scroll-margin-top: 24px;
}


.icon-btn{
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  border:1px solid transparent;
  font-weight:800;
  cursor:pointer;
  padding:0;
  line-height:1;
  background:#fff;
}
.icon-btn:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.icon-btn-up{
  color:#0F6A5A;
  border-color:rgba(15,106,90,.28);
  background:rgba(15,106,90,.08);
}
.icon-btn-up:hover:not(:disabled){ background:rgba(15,106,90,.14); }
.icon-btn-down{
  color:#8B1E3F;
  border-color:rgba(139,30,63,.28);
  background:rgba(139,30,63,.08);
}
.icon-btn-down:hover:not(:disabled){ background:rgba(139,30,63,.14); }
.icon-btn-delete{
  color:#8B1E3F;
  border-color:rgba(139,30,63,.32);
  background:rgba(139,30,63,.12);
}
.icon-btn-delete:hover:not(:disabled){ background:rgba(139,30,63,.18); }
.actions{
  display:flex;
  gap:6px;
  flex-wrap:nowrap;
}

.alert{
  padding:12px 16px;
  border-radius:12px;
  margin-bottom:15px;
  font-weight:600;
}
.alert.success{
  background:#ecfdf5;
  color:#065f46;
  border:1px solid #34d399;
}
.alert.error{
  background:#fef2f2;
  color:#7f1d1d;
  border:1px solid #f87171;
}


.notice-success{
  background:#ecfdf5;
  color:#166534;
  border:1px solid #86efac;
}
.notice-error{
  background:#fef2f2;
  color:#991b1b;
  border:1px solid #fca5a5;
}


.stat-line-group{
  margin-top: 18px;
}
.stat-line{
  display:flex;
  align-items:baseline;
  gap:12px;
  flex-wrap:wrap;
}
.stat-inline-label{
  font-size: 16px;
  font-weight: 700;
  color: #253043;
}
.stat-inline-name{
  font-size: 16px;
  font-weight: 700;
  color: #253043;
}

}
.rules-link-wrap{
  margin-top: 18px;
}
.rules-link{
  color: var(--burgundy);
  font-weight: 700;
  text-decoration: underline;
}


/* Uniform body/meta text size */
.meta, .rules-copy {
  font-size: 14px !important;
  line-height: 1.6;
}

.rules-copy{max-width:none !important;width:100%;}


.player-record{
  font-size: 12px;
  line-height: 1.45;
  color: #667085;
  margin-top: 2px;
}


.player-link{
  color: var(--burgundy);
  font-weight: 600;
  text-decoration: none;
}
.player-link:hover{
  text-decoration: underline;
}

.history-table{
  width:100%;
  border-collapse: collapse;
  margin-top:15px;
}

.history-table th{
  background: var(--burgundy);
  color:#fff;
  text-align:left;
  padding:10px;
  font-size:13px;
}

.history-table td{
  padding:10px;
  border-bottom:1px solid #eee;
  font-size:13px;
}

.result-win{ color:#0F6A5A; font-weight:600; }
.result-loss{ color:#8B1E3F; font-weight:600; }
.result-draw{ color:#667085; font-weight:600; }


.history-table-wrap{
  overflow-x:auto;
  border:1px solid #ead4db;
  border-radius:16px;
}
.history-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  margin-top:0;
}
.history-table thead th{
  background:#8B1E3F;
  color:#fff;
  text-align:left;
  padding:12px 14px;
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
}
.history-table thead th:first-child{
  border-top-left-radius:14px;
}
.history-table thead th:last-child{
  border-top-right-radius:14px;
}
.history-table tbody td{
  padding:10px 14px;
  border-bottom:1px solid #eee;
  font-size:13px;
}
.history-back-top{
  margin-top:14px;
}
.history-back-top a{
  color:#8B1E3F;
  font-weight:700;
  text-decoration:underline;
}

.footer img{height:36px;}


/* Responsive sponsor card improvements */
.sponsor-card{
  align-items: center;
}
.sponsor-card .sponsor-logo-wrap{
  width: 100%;
  display: flex;
  justify-content: center;
}
.sponsor-card .sponsor-logo{
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 1100px){
  .sponsor-card{
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }
  .sponsor-card .sponsor-logo-wrap{
    justify-content: flex-start;
  }
  .sponsor-card .sponsor-logo{
    max-width: 420px;
  }
}

@media (max-width: 820px){
  .sponsor-card{
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .sponsor-card .sponsor-logo-wrap{
    justify-content: center;
  }
  .sponsor-card .sponsor-logo{
    max-width: 100%;
  }
}


/* Sponsor card robust fix */
.sponsor-card{
  overflow: visible !important;
  flex-wrap: nowrap;
  align-items: center;
}
.sponsor-card > div:first-child{
  flex: 0 1 240px;
  min-width: 0;
}
.sponsor-card .sponsor-logo-wrap{
  flex: 1 1 420px;
  min-width: 0;
  width: auto !important;
  max-width: 100%;
}
.sponsor-card .sponsor-logo-wrap a{
  display: block;
  width: 100%;
}
.sponsor-card .sponsor-logo{
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 1200px){
  .sponsor-card{
    flex-wrap: wrap;
  }
  .sponsor-card > div:first-child,
  .sponsor-card .sponsor-logo-wrap{
    flex: 1 1 100%;
  }
  .sponsor-card .sponsor-logo-wrap{
    width: 100% !important;
  }
}


/* Mobile sponsor hard fix */
@media (max-width: 700px){
  .sponsor-card{
    display:block !important;
    overflow:hidden !important;
  }
  .sponsor-card > div:first-child{
    width:100% !important;
    max-width:100% !important;
    margin-bottom:14px;
  }
  .sponsor-card .sponsor-logo-wrap{
    display:block !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    padding:10px !important;
    box-sizing:border-box !important;
    overflow:hidden !important;
  }
  .sponsor-card .sponsor-logo-wrap a{
    display:block !important;
    width:100% !important;
    max-width:100% !important;
  }
  .sponsor-card .sponsor-logo{
    display:block !important;
    width:100% !important;
    max-width:100% !important;
    height:auto !important;
    object-fit:contain !important;
  }
}


.log-table-wrap{
  overflow-x:auto;
  border:1px solid #ead4db;
  border-radius:16px;
}
.log-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}
.log-table thead th{
  background:#8B1E3F;
  color:#fff;
  text-align:left;
  padding:12px 14px;
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
}
.log-table thead th:first-child{border-top-left-radius:14px;}
.log-table thead th:last-child{border-top-right-radius:14px;}
.log-table tbody td{
  padding:10px 14px;
  border-bottom:1px solid #eee;
  font-size:13px;
}
.log-success{
  color:#0F6A5A;
  font-weight:700;
}
.log-failed{
  color:#8B1E3F;
  font-weight:700;
}


.inline-form{ display:inline-block; }
.btn-small{ padding:8px 12px; font-size:12px; }


.player-link-row{
  display:flex;
  align-items:center;
  gap:8px;
}
.player-status-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:16px;
  font-size:14px;
  font-weight:800;
}
.player-status-icon.status-win{ color:#0F6A5A; }
.player-status-icon.status-loss{ color:#8B1E3F; }
.player-status-icon.status-draw,
.player-status-icon.status-none{ color:#667085; }

.position-cell{
  white-space:nowrap;
}
.position-cell strong{
  font-weight:800;
}
.position-cell.position-win strong{ color:#0F6A5A; }
.position-cell.position-loss strong{ color:#8B1E3F; }
.position-cell.position-draw strong{ color:#253043; }
.position-arrow{
  margin:0 6px;
  color:#667085;
}


.stat-sentence{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  font-size:16px;
  line-height:1.5;
  color:#253043;
}
.stat-emoji{
  font-size:18px;
  line-height:1;
}


/* Admin blocks align with the main cards above and stay responsive */
.admin-centered-block{
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}
.log-table-wrap,
.history-table-wrap{
  width: 100%;
  max-width: 100%;
}
