:root {
    --navy-900: #071a45;
    --navy-800: #0b2560;
    --navy-700: #103a8f;
    --blue: #1a56c4;
    --cyan: #2ba8e0;
    --cream: #ecd3a8;
    --gold: #e3b878;
    --white: #ffffff;
    --muted: rgba(255, 255, 255, 0.62);
    --line: rgba(255, 255, 255, 0.12);
    --panel: rgba(255, 255, 255, 0.055);
    --panel-strong: rgba(255, 255, 255, 0.09);
    --radius: 16px;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Barlow', system-ui, sans-serif;
    color: var(--white);
    background:
        radial-gradient(1100px 600px at 82% -8%, rgba(43, 168, 224, 0.28), transparent 60%),
        radial-gradient(900px 620px at 8% 108%, rgba(26, 86, 196, 0.35), transparent 60%),
        linear-gradient(160deg, var(--navy-700) 0%, var(--navy-800) 42%, var(--navy-900) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ---- Decorative stars ---- */
.bg-stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-stars .star { position: absolute; opacity: 0.12; }
.bg-stars .star polygon { fill: none; stroke-width: 3; }
.star-gold { width: 340px; height: 340px; top: 4%; right: -70px; transform: rotate(14deg); }
.star-gold polygon { stroke: var(--cream); }
.star-cyan { width: 260px; height: 260px; bottom: 6%; left: -60px; transform: rotate(-12deg); }
.star-cyan polygon { stroke: var(--cyan); opacity: 0.9; }

/* ---- Layout shell ---- */
.site-header, .site-main, .site-footer {
    position: relative;
    z-index: 1;
    width: min(1040px, 100% - 32px);
    margin-inline: auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 0 14px;
    flex-wrap: wrap;
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--white); }
.brand-logo { height: 54px; width: auto; display: block; }
.brand-crest { display: grid; place-items: center; width: 46px; height: 46px; }
.crest-star { width: 46px; height: 46px; }
.crest-star polygon { fill: none; stroke: var(--cream); stroke-width: 4; }
.brand-text { display: flex; flex-direction: column; line-height: 0.92; }
.brand-top { font-family: 'Saira Condensed', sans-serif; font-weight: 800; font-style: italic; font-size: 1.5rem; letter-spacing: 0.04em; }
.brand-bottom { font-family: 'Saira Condensed', sans-serif; font-weight: 600; font-size: 0.85rem; letter-spacing: 0.32em; color: var(--cream); }

.site-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-nav a {
    color: var(--white);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 8px 14px;
    border-radius: 999px;
    opacity: 0.82;
    transition: background 0.15s, opacity 0.15s;
}
.site-nav a:hover { opacity: 1; background: var(--panel); }
.site-nav a.active { background: var(--cream); color: var(--navy-900); opacity: 1; }

.site-main { padding: 18px 0 60px; }

.site-footer {
    padding: 26px 0 40px;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--line);
    margin-top: 20px;
}

/* ---- Panels ---- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    backdrop-filter: blur(4px);
}
.empty { text-align: center; color: var(--muted); padding: 48px 22px; }

/* ---- Hero ---- */
.hero { padding: 26px 0 30px; }
.hero-kicker, .ranking-head .hero-kicker {
    text-transform: uppercase;
    letter-spacing: 0.26em;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--cyan);
    margin: 0 0 10px;
}
.hero-title {
    font-family: 'Saira Condensed', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(2.4rem, 7vw, 4.3rem);
    line-height: 0.92;
    margin: 0;
    text-transform: uppercase;
}
.hero-title span { color: var(--cream); }
.hero-sub { color: var(--muted); font-size: 1.05rem; margin: 14px 0 0; }

/* ---- Tournament blocks & game cards ---- */
.tournament-block { margin-top: 34px; }
.tournament-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.tournament-head h2 {
    font-family: 'Saira Condensed', sans-serif;
    font-weight: 800; font-style: italic; text-transform: uppercase;
    font-size: 1.8rem; margin: 0; letter-spacing: 0.01em;
}
.chip {
    font-size: 0.78rem; font-weight: 600;
    color: var(--navy-900); background: var(--cream);
    padding: 4px 12px; border-radius: 999px;
}

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.game-card {
    display: flex; align-items: center; gap: 14px;
    text-decoration: none; color: var(--white);
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 16px 18px;
    transition: transform 0.14s, border-color 0.14s, background 0.14s;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--cyan); background: var(--panel-strong); }
.game-card-icon { width: 38px; height: 38px; flex: 0 0 auto; }
.game-card-icon svg { width: 38px; height: 38px; }
.game-card-icon polygon { fill: var(--cyan); }
.game-card-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.game-card-name { font-weight: 700; font-size: 1.08rem; }
.game-card-type { color: var(--muted); font-size: 0.82rem; }
.game-card-arrow { color: var(--cream); font-size: 1.3rem; font-weight: 700; }

/* ---- Ranking ---- */
.back-link { display: inline-block; color: var(--cyan); text-decoration: none; font-weight: 600; margin-bottom: 18px; }
.back-link:hover { color: var(--white); }
.ranking-head { margin-bottom: 20px; }
.ranking-title {
    font-family: 'Saira Condensed', sans-serif; font-weight: 800; font-style: italic;
    text-transform: uppercase; font-size: clamp(2rem, 6vw, 3.3rem); margin: 0; line-height: 0.95;
}
.ranking-sub { color: var(--muted); margin: 8px 0 0; }

.ranking-table-wrap { padding: 8px; overflow-x: auto; }
.ranking-table { width: 100%; border-collapse: collapse; min-width: 440px; }
.ranking-table thead th {
    text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--muted); font-weight: 700; padding: 12px 16px; white-space: nowrap;
}
.ranking-table tbody td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.ranking-table .col-pos { width: 56px; }
.ranking-table .col-result { text-align: right; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.player-name { font-weight: 600; }
.player-group { color: var(--muted); }

.pos-badge {
    display: inline-grid; place-items: center; width: 32px; height: 32px;
    border-radius: 50%; background: var(--panel-strong); border: 1px solid var(--line);
    font-weight: 700; font-size: 0.95rem;
}
.podium td { background: rgba(255, 255, 255, 0.03); }
.podium-1 .pos-badge { background: linear-gradient(145deg, #f6d070, #d99b2c); color: #4a2c00; border: none; }
.podium-2 .pos-badge { background: linear-gradient(145deg, #e3e8ef, #aab6c6); color: #2a3442; border: none; }
.podium-3 .pos-badge { background: linear-gradient(145deg, #e6a97a, #b9703f); color: #3a1c08; border: none; }
.podium-1 .col-result { color: var(--cream); }

/* ---- Admin ---- */
.admin-head h1, .login-panel h1, .notfound h1 {
    font-family: 'Saira Condensed', sans-serif; font-weight: 800; font-style: italic;
    text-transform: uppercase; font-size: 2.2rem; margin: 0 0 6px;
}
.admin-head p { color: var(--muted); margin: 0 0 20px; }
.admin-form { display: flex; flex-direction: column; gap: 16px; }
.admin-tournament { padding: 18px 20px; }
.admin-toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.admin-toggle input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--cyan); }
.admin-toggle-label { display: flex; flex-direction: column; }
.admin-toggle-label strong { font-size: 1.2rem; }
.admin-toggle-label small { color: var(--muted); }
.admin-games { margin: 14px 0 0; padding: 14px 0 0 30px; border-top: 1px solid var(--line); }
.admin-games-title { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 10px; }
.admin-game { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.admin-game input { width: 16px; height: 16px; accent-color: var(--cyan); }
.admin-game em { color: var(--muted); font-style: normal; font-size: 0.85rem; }
.admin-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }

/* ---- Buttons & forms ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 0.95rem;
    text-decoration: none; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--cream); color: var(--navy-900); }
.btn-primary:hover { background: var(--white); }
.btn-ghost { background: transparent; color: var(--white); border-color: var(--line); }
.btn-ghost:hover { background: var(--panel); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field span { font-size: 0.85rem; color: var(--muted); }
.field input {
    padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.22); color: var(--white); font-size: 1rem;
}
.field input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }

.login-wrap { display: grid; place-items: center; padding: 50px 0; }
.login-panel { width: min(400px, 100%); }

/* ---- Alerts ---- */
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.alert-ok { background: rgba(43, 168, 224, 0.16); border: 1px solid rgba(43, 168, 224, 0.5); }
.alert-error { background: rgba(224, 72, 72, 0.16); border: 1px solid rgba(224, 72, 72, 0.5); }
.alert code { color: var(--cream); }

@media (max-width: 560px) {
    .site-header { padding-top: 16px; }
    .brand-logo { height: 42px; }
    .ranking-table .player-group { display: none; }
    .ranking-table thead th:nth-child(3) { display: none; }
}
