:root {
  --bg: #f8fafc;
  --paper: #ffffff;
  --ink: #122033;
  --muted: #64748b;
  --line: #dbe4ef;
  --accent: #b91c1c;
  --accent2: #0f766e;
  --accent3: #1d4ed8;
  --softRed: #fee2e2;
  --softGreen: #dcfce7;
  --softBlue: #dbeafe;
  --shadow: 0 20px 50px rgba(15, 23, 42, .10);
  --radius: 22px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(185, 28, 28, .14), transparent 32rem),
    radial-gradient(circle at 88% 8%, rgba(15, 118, 110, .12), transparent 28rem),
    linear-gradient(180deg, #fff7ed 0%, var(--bg) 36%);
  line-height: 1.55;
}
a { color: var(--accent3); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
.page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 52px; }
.hero {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius) + 8px);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .95), rgba(88, 28, 28, .91)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 18px, transparent 18px 36px);
  color: white;
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 56px);
  min-height: 280px;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 26px;
  align-items: center;
}
.hero:after {
  content: "";
  position: absolute;
  width: 290px;
  height: 290px;
  right: -58px;
  bottom: -80px;
  border-radius: 50%;
  border: 34px solid rgba(255,255,255,.08);
}
.heroText { position: relative; z-index: 1; }
.hero h1 { margin: 0 0 14px; font-size: clamp(2rem, 5vw, 4rem); line-height: 1.02; letter-spacing: -.05em; max-width: 820px; }
.hero p { margin: 0; color: rgba(255,255,255,.82); max-width: 760px; font-size: clamp(1rem, 1.5vw, 1.16rem); }
.heroActions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.25);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(15,23,42,.12);
}
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.button:hover { transform: translateY(-1px); color: inherit; }
.summaryCards { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.18); border-radius: 20px; padding: 18px; backdrop-filter: blur(8px); }
.stat small { display: block; color: rgba(255,255,255,.70); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; }
.stat strong { display: block; margin-top: 6px; font-size: clamp(1.35rem, 3vw, 2.25rem); line-height: 1.05; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; margin-top: 26px; align-items: start; }
.panel { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.panelHeader { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
h2 { margin: 0 0 4px; font-size: 1.25rem; }
.panel p { margin: 0; color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
input, select, textarea { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; background: #fff; color: var(--ink); }
textarea { width: 100%; margin: 8px 0 12px; resize: vertical; }
#searchInput { min-width: 260px; }
.tableWrap, .adminTableWrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f1f5f9; color: #334155; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #fff7ed; }
tbody tr.noTournament { background: #f8fafc; color: #64748b; }
tbody tr.hidden { display: none; }
.yearCell { font-weight: 900; white-space: nowrap; }
.winnerCell { font-weight: 800; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: .78rem; font-weight: 900; white-space: nowrap; }
.badge.live { background: var(--softGreen); color: #166534; }
.badge.muted { background: #e2e8f0; color: #475569; }
.empty { display: none; margin-top: 16px; padding: 18px; border-radius: 16px; background: #fff7ed; color: #9a3412; font-weight: 800; }
.leaderboard ol { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.leaderboard li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 15px; padding: 10px; }
.rank { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--softBlue); color: #1e40af; font-weight: 900; }
.name { font-weight: 800; }
.footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 26px; color: var(--muted); font-size: .95rem; }
.adminBody { background: #f8fafc; }
.adminHeader { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.adminHeader h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.04em; }
.adminHeader p { margin: 0; color: var(--muted); }
.adminLinks { display: flex; gap: 10px; flex-wrap: wrap; }
.notice { padding: 14px 16px; border-radius: 14px; margin: 10px 0; font-weight: 800; }
.notice.success { background: #dcfce7; color: #166534; }
.notice.error { background: #fee2e2; color: #991b1b; }
.loginPanel, .adminPanel { margin-bottom: 20px; }
.loginForm { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.loginForm label, .gridForm label { display: grid; gap: 6px; font-weight: 800; color: #334155; }
.helpText { color: var(--muted); font-size: .95rem; }
.gridForm { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.gridForm input, .gridForm select { width: 100%; }
.adminTable { min-width: 1300px; font-size: .92rem; }
.adminTable input, .adminTable select { width: 100%; min-width: 120px; padding: 8px 9px; border-radius: 9px; }
.adminTable .smallInput { min-width: 82px; }
.deleteCell { text-align: center; }
.deleteCell input { min-width: auto; width: 20px; height: 20px; }
.stickySave { position: sticky; bottom: 12px; display: flex; justify-content: flex-end; margin-top: 12px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; }
@media (max-width: 900px) {
  .hero, .content-grid { grid-template-columns: 1fr; }
  .summaryCards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panelHeader, .adminHeader { flex-direction: column; }
  .filters { justify-content: stretch; }
  #searchInput, .filters select { width: 100%; min-width: 0; }
  .gridForm { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page { width: min(100% - 18px, 1180px); padding-top: 12px; }
  .summaryCards { grid-template-columns: 1fr; }
  th, td { padding: 10px; }
}
@media print {
  body { background: white; }
  .page { width: 100%; padding: 0; }
  .hero, .panel { box-shadow: none; }
  .filters, .heroActions, .footer, .leaderboard, .adminLinks, .button { display: none !important; }
  .content-grid { display: block; }
  a { color: inherit; text-decoration: none; }
}
