:root {
  --ink: #172033;
  --muted: #6c7485;
  --paper: #ffffff;
  --canvas: #f5f6fa;
  --line: #e7e9f0;
  --brand: #6d4aff;
  --brand-dark: #4c2de0;
  --accent: #ffcf40;
  --green: #168a5b;
  --red: #c84242;
  --blue: #2e6ce6;
  --shadow: 0 18px 50px rgba(31, 38, 62, .09);
  --radius: 24px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: "DM Sans", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Manrope", sans-serif; letter-spacing: -.035em; }
h1 { font-size: clamp(2.2rem, 5vw, 4.7rem); line-height: .98; margin-bottom: 22px; }
h2 { font-size: clamp(1.45rem, 2vw, 2rem); margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.site-shell { width: min(1440px, 100%); margin: 0 auto; min-height: 100vh; }
.hero { position: relative; overflow: hidden; color: #fff; padding: 26px clamp(22px, 5vw, 72px) 80px; background: radial-gradient(circle at 86% 5%, rgba(255,255,255,.19), transparent 26%), linear-gradient(135deg, #211646 0%, #5938d7 52%, #825fff 100%); border-radius: 0 0 42px 42px; }
.hero::after { content: "?"; position: absolute; right: 4%; bottom: -34%; font: 800 clamp(240px, 34vw, 520px)/1 "Manrope"; color: rgba(255,255,255,.055); transform: rotate(10deg); pointer-events: none; }
.topbar, .hero__content, .section, .footer { max-width: 1280px; margin-left: auto; margin-right: auto; }
.topbar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-family: "Manrope"; font-weight: 800; }
.brand__logo-wrap { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.12); box-shadow: 0 10px 28px rgba(0,0,0,.16); overflow: hidden; }
.brand__logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand--dark { color: var(--ink); }
.brand--dark .brand__logo-wrap { background: #eef0f5; box-shadow: none; }
.quarter-switcher select { border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 10px 34px 10px 14px; background: rgba(255,255,255,.12); color: #fff; }
.quarter-switcher option { color: var(--ink); }
.hero__content { position: relative; z-index: 1; display: grid; grid-template-columns: 1.2fr .8fr; align-items: end; gap: 56px; padding-top: 78px; }
.hero__copy { max-width: 680px; margin-bottom: 0; color: rgba(255,255,255,.75); font-size: 1.08rem; line-height: 1.7; }
.eyebrow { margin-bottom: 12px; color: var(--brand); font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: var(--accent); }
.hero__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { min-width: 0; padding: 20px 16px; border: 1px solid rgba(255,255,255,.15); border-radius: 18px; background: rgba(255,255,255,.09); backdrop-filter: blur(12px); }
.stat strong { display: block; font: 800 1.75rem/1 "Manrope"; }
.stat span { display: block; margin-top: 8px; color: rgba(255,255,255,.67); font-size: .76rem; }
.section { padding: 62px clamp(20px, 4vw, 48px) 0; }
.section-heading, .card-heading, .admin-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.status-badge, .updated { padding: 8px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: .82rem; font-weight: 700; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 18px; }
.podium-card { position: relative; min-height: 300px; padding: 32px; overflow: hidden; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.podium-card--rank-1 { min-height: 340px; padding-top: 46px; background: linear-gradient(155deg, #fff9d9 0%, #fff 65%); border-color: #f0d86b; }
.podium-card--rank-2 { background: linear-gradient(155deg, #f1f3f8 0%, #fff 65%); }
.podium-card--rank-3 { background: linear-gradient(155deg, #fbede4 0%, #fff 65%); }
.podium-card__badge { position: absolute; top: 16px; right: 18px; font-size: 1.6rem; }
.podium-card h3 { margin: 18px 0 10px; font-size: 1.28rem; }
.podium-card p { margin: 16px 0 0; color: var(--muted); font-size: .85rem; }
.podium-card__score strong { display: block; font: 800 2.7rem/1 "Manrope"; }
.podium-card__score span { color: var(--muted); font-size: .8rem; }
.avatar { flex: 0 0 auto; object-fit: cover; border-radius: 50%; background: linear-gradient(135deg, #ece7ff, #d9d0ff); color: var(--brand-dark); font-weight: 800; }
.avatar--initials { display: inline-grid; place-items: center; }
.avatar--xl { width: 92px; height: 92px; font-size: 1.55rem; border: 6px solid rgba(255,255,255,.8); box-shadow: 0 12px 28px rgba(61,43,124,.14); }
.avatar--md { width: 48px; height: 48px; }
.avatar--sm { width: 38px; height: 38px; font-size: .8rem; }
.avatar--xs { width: 30px; height: 30px; font-size: .68rem; }
.leaderboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 22px; align-items: start; padding-bottom: 64px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.table-card, .latest-card, .rules-card, .admin-section { padding: 28px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 15px 12px; text-align: center; border-bottom: 1px solid var(--line); font-size: .9rem; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
th:nth-child(2), td:nth-child(2) { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.is-top { background: #fbfaff; }
.player-cell { display: flex; align-items: center; gap: 11px; min-width: 170px; }
.rank-pill { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 10px; background: #f0f1f5; font-weight: 800; }
.rank-pill--1 { background: #ffed9c; }
.rank-pill--2 { background: #e5e8ef; }
.rank-pill--3 { background: #f6d5c0; }
.points { font-size: 1.05rem; }
.movement { display: inline-block; min-width: 38px; font-weight: 800; }
.movement--up { color: var(--green); }
.movement--down { color: var(--red); }
.movement--new { color: var(--blue); font-size: .68rem; }
.movement--same { color: #a6abba; }
.side-stack { display: grid; gap: 22px; }
.latest-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.latest-list li { display: grid; grid-template-columns: 28px 30px 1fr auto; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.latest-list li:last-child { border-bottom: 0; }
.latest-list__place { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; background: var(--canvas); font-size: .78rem; font-weight: 800; }
.latest-list__points { color: var(--green); font-weight: 800; }
.score-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 20px; }
.score-grid div { padding: 12px 6px; text-align: center; border-radius: 14px; background: var(--canvas); }
.score-grid span, .score-grid strong { display: block; }
.score-grid span { color: var(--muted); font-size: .72rem; }
.score-grid strong { margin-top: 4px; font-size: .83rem; }
.rules-note { margin: 18px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.empty-state { max-width: 800px; margin: 60px auto; padding: 64px 30px; text-align: center; }
.empty-state__icon { margin-bottom: 16px; font-size: 3rem; }
.empty-state p { color: var(--muted); }
.footer { display: flex; justify-content: space-between; padding: 0 clamp(20px, 4vw, 48px) 32px; color: var(--muted); font-size: .8rem; }
.footer a:hover { color: var(--brand); }

/* Forms and admin */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #ece8ff, transparent 32%), var(--canvas); }
.auth-shell--wide { align-items: start; padding-top: 70px; }
.auth-card { width: min(480px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 58px; }
.auth-card p { color: var(--muted); line-height: 1.6; }
.auth-card--wide { width: min(850px, 100%); }
.auth-card--wide .brand { margin-bottom: 0; }
.form-stack, .result-form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; color: var(--ink); font-size: .82rem; font-weight: 700; }
.field input, .field select, .quarter-switcher select { outline: none; }
.field input, .field select { width: 100%; padding: 13px 14px; border: 1px solid #dfe2eb; border-radius: 12px; background: #fff; color: var(--ink); transition: .2s ease; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(109,74,255,.1); }
.optional { color: var(--muted); font-weight: 500; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-weight: 800; transition: transform .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button--primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.button--primary:hover { background: var(--brand-dark); }
.button--secondary { background: #fff; }
.button--ghost { width: 100%; color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.13); }
.button--small { min-height: 34px; padding: 0 11px; border-radius: 9px; font-size: .76rem; }
.button--danger { color: var(--red); background: #fff7f7; border-color: #f1cccc; }
.text-link { display: inline-block; margin-top: 20px; color: var(--brand); font-weight: 700; font-size: .85rem; }
.flash { margin-bottom: 20px; padding: 13px 15px; border-radius: 12px; font-size: .86rem; font-weight: 700; }
.flash--success { color: #0d7149; background: #e8f7f0; border: 1px solid #bee8d5; }
.flash--error { color: #a43434; background: #fff0f0; border: 1px solid #efc9c9; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.admin-nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 22px; color: #fff; background: #211a3b; }
.admin-nav nav { display: grid; gap: 6px; margin: 64px 0 auto; }
.admin-nav nav a { padding: 11px 12px; border-radius: 10px; color: rgba(255,255,255,.7); font-weight: 700; font-size: .86rem; }
.admin-nav nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.admin-main { width: min(1150px, 100%); margin: 0 auto; padding: 50px 38px 90px; }
.admin-header h1 { font-size: clamp(2.1rem, 4vw, 3.6rem); margin-bottom: 0; }
.admin-section { margin-top: 24px; scroll-margin-top: 20px; }
.placement-fields { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; margin-bottom: 12px; padding: 18px; border-radius: 16px; background: var(--canvas); }
.inline-form--participants { grid-template-columns: 1fr auto; }
.quarter-form { grid-template-columns: 1fr 1fr 1fr auto; }
.helper-note { margin: 0 0 22px; color: var(--muted); font-size: .84rem; }
.participant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.participant-card { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; }
.participant-card span { display: block; margin-top: 4px; color: var(--muted); font-size: .76rem; }
.participant-card.is-inactive { opacity: .55; }
.admin-list { display: grid; gap: 9px; }
.admin-list__row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.admin-list__row:last-child { border-bottom: 0; }
.admin-list__row span { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions form { margin: 0; }
.status-badge { color: var(--brand-dark); background: #f2efff; border-color: #ddd5ff; text-transform: capitalize; }
.status-badge--completed { color: var(--muted); background: #f5f6f8; border-color: var(--line); }
.inline-empty { padding: 30px; text-align: center; border: 1px dashed #d7d9e2; border-radius: 16px; color: var(--muted); }
.inline-empty p { margin: 6px 0 0; }

@media (max-width: 980px) {
  .hero__content, .leaderboard-grid { grid-template-columns: 1fr; }
  .hero__stats { max-width: 600px; }
  .podium { gap: 10px; }
  .podium-card { padding: 24px 14px; }
  .placement-fields { grid-template-columns: repeat(2, 1fr); }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { position: static; height: auto; flex-direction: row; align-items: center; gap: 20px; }
  .admin-nav nav { display: none; }
  .admin-nav form { margin-left: auto; }
  .admin-nav .button { width: auto; }
}
@media (max-width: 680px) {
  .hero { padding-bottom: 52px; border-radius: 0 0 28px 28px; }
  .hero__content { padding-top: 58px; }
  .hero__stats { grid-template-columns: 1fr; }
  .section { padding-top: 44px; }
  .section-heading, .card-heading, .admin-header { align-items: flex-start; flex-direction: column; }
  .podium { display: flex; overflow-x: auto; padding-bottom: 10px; }
  .podium-card, .podium-card--rank-1 { min-width: 230px; min-height: 280px; }
  .table-card, .latest-card, .rules-card, .admin-section { padding: 20px; }
  .footer { gap: 20px; }
  .admin-main { padding: 32px 16px 70px; }
  .admin-nav { padding: 18px 16px; }
  .admin-nav .brand span:last-child { display: none; }
  .placement-fields, .participant-grid { grid-template-columns: 1fr; }
  .inline-form, .quarter-form, .inline-form--participants { grid-template-columns: 1fr; }
  .admin-list__row { align-items: flex-start; }
  .auth-card { padding: 28px 22px; }
}
