:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --text: #111827;
    --muted: #667085;
    --border: #d9e0ea;
    --brand: #111827;
    --brand-2: #334155;
    --accent: #d9a441;
    --danger: #b42318;
    --success: #027a48;
    --warning: #b54708;
    --shadow: 0 20px 50px rgba(15, 23, 42, .08);
}
:root[data-theme="dark"] {
    --bg: #0b1120;
    --surface: #121a2c;
    --surface-2: #1d273a;
    --text: #e5e7eb;
    --muted: #9aa4b2;
    --border: #293548;
    --brand: #f8fafc;
    --brand-2: #cbd5e1;
    --accent: #e7b95a;
    --danger: #f97066;
    --success: #32d583;
    --warning: #fdb022;
    --shadow: 0 20px 50px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 40px; height: 40px; border-radius: 14px; background: var(--brand); color: var(--bg); display: grid; place-items: center; font-size: 23px; box-shadow: var(--shadow); }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .theme-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 10px 14px; font-size: 14px; font-weight: 700; cursor: pointer; }
.nav a:hover, .theme-toggle:hover { border-color: var(--accent); }
.theme-toggle { width: 44px; height: 42px; display: grid; place-items: center; font-size: 18px; }
.hero { padding: 64px 0 32px; }
.hero-card { display: grid; grid-template-columns: 1.2fr .8fr; gap: 28px; align-items: center; background: linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--border); border-radius: 32px; padding: 38px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero-card:after { content: ""; position: absolute; right: -90px; top: -90px; width: 260px; height: 260px; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), transparent 68%); pointer-events: none; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--brand-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 12px; font-weight: 800; font-size: 13px; }
h1 { font-size: clamp(36px, 6vw, 68px); line-height: .95; margin: 18px 0; letter-spacing: -.06em; }
h2 { font-size: clamp(24px, 3vw, 36px); letter-spacing: -.04em; margin: 0 0 16px; }
h3 { margin: 0 0 8px; font-size: 20px; }
p { color: var(--muted); line-height: 1.65; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid var(--border); border-radius: 14px; padding: 10px 16px; background: var(--surface); color: var(--text); font-weight: 800; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--bg); }
.btn-accent { background: var(--accent); color: #111827; border-color: var(--accent); }
.btn-danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-small { min-height: 34px; padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.chess-visual { min-height: 300px; display: grid; place-items: center; }
.board { width: min(340px, 100%); aspect-ratio: 1/1; display: grid; grid-template-columns: repeat(8, 1fr); border-radius: 28px; overflow: hidden; border: 8px solid var(--surface); box-shadow: var(--shadow); transform: rotate(-4deg); }
.square { display: grid; place-items: center; font-size: clamp(16px, 3vw, 31px); }
.square:nth-child(odd) { background: #e8dcc5; color: #111827; }
.square:nth-child(even) { background: #334155; color: #f8fafc; }
.section { padding: 28px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); }
.tournament-card { display: flex; flex-direction: column; gap: 12px; min-height: 100%; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--brand-2); font-size: 12px; font-weight: 800; text-transform: capitalize; }
.badge-open, .badge-approved, .badge-completed { color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface)); border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.badge-running, .badge-scheduled { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.badge-draft, .badge-pending { color: var(--muted); }
.badge-rejected, .badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.info-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: auto; }
.info-item { padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.info-item strong { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; padding: 28px 0; align-items: start; }
.sidebar { position: sticky; top: 92px; }
.sidebar .card { padding: 12px; }
.sidebar a { display: flex; padding: 12px; border-radius: 13px; font-weight: 800; color: var(--muted); }
.sidebar a:hover, .sidebar a.active { background: var(--surface-2); color: var(--text); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { display: block; font-size: 30px; letter-spacing: -.04em; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-weight: 800; font-size: 13px; margin-bottom: 7px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 12px 13px; background: var(--surface); color: var(--text); outline: none; font: inherit; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.flash { margin-top: 18px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font-weight: 750; }
.flash-success { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); color: var(--success); }
.flash-warning { border-color: color-mix(in srgb, var(--warning) 35%, var(--border)); color: var(--warning); }
.flash-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); color: var(--danger); }
.match-card { border: 1px solid var(--border); background: var(--surface); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.match-row { display: grid; grid-template-columns: 80px 1fr 180px; gap: 12px; align-items: center; }
.player-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.player-line:last-child { border-bottom: 0; }
.standings-rank { width: 34px; height: 34px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 900; }
.login-wrap { min-height: calc(100vh - 260px); display: grid; place-items: center; padding: 46px 0; }
.login-card { width: min(440px, 100%); }
.empty { padding: 36px; text-align: center; border: 1px dashed var(--border); border-radius: 22px; background: var(--surface); color: var(--muted); }
.site-footer { margin-top: 42px; padding: 34px 0; border-top: 1px solid var(--border); background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 22px; }
.footer-brand { font-weight: 900; font-size: 20px; margin-bottom: 8px; }
.install-page { padding: 44px 0; }
.install-card { width: min(860px, 100%); margin: 0 auto; }
.codebox { display: block; overflow-x: auto; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.pagination { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pagination a, .pagination span { border: 1px solid var(--border); background: var(--surface); padding: 8px 12px; border-radius: 12px; font-weight: 800; }
.pagination .active { background: var(--brand); color: var(--bg); }
@media (max-width: 900px) {
    .hero-card, .layout, .footer-grid { grid-template-columns: 1fr; }
    .grid, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar { position: static; }
    .match-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .container { width: min(100% - 22px, 1180px); }
    .topbar-inner { align-items: flex-start; flex-direction: column; padding: 12px 0; }
    .nav { width: 100%; justify-content: flex-start; }
    .nav a { font-size: 13px; padding: 9px 11px; }
    .hero { padding-top: 24px; }
    .hero-card { padding: 24px; border-radius: 24px; }
    .grid, .stat-grid, .info-list, .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
}

.checkbox-row { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; line-height: 1.55; margin-top: 16px; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 3px; accent-color: var(--accent); }
.legal-consent { padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.legal-content { max-width: 920px; margin: 0 auto; }
.legal-content h1 { font-size: clamp(34px, 5vw, 54px); }
.legal-content h2 { margin-top: 28px; }
.footer-grid { grid-template-columns: 1.35fr 1fr 1fr 1fr; }
.footer-links { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.footer-links a { color: var(--muted); font-weight: 800; }
.footer-links a:hover { color: var(--text); }
.cookie-banner { position: fixed; left: 18px; right: 18px; bottom: 18px; z-index: 50; display: flex; justify-content: space-between; align-items: center; gap: 18px; width: min(980px, calc(100% - 36px)); margin: 0 auto; padding: 16px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 4px 0 0; }
.cookie-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 900px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .cookie-banner { align-items: flex-start; flex-direction: column; }
    .cookie-actions { justify-content: flex-start; }
}
@media (max-width: 640px) {
    .footer-grid { grid-template-columns: 1fr; }
    .checkbox-row { font-size: 14px; }
}
