:root {
    --bg: #070a12;
    --surface: #0d1422;
    --surface-2: #111b2c;
    --panel: rgba(14, 22, 36, .9);
    --ink: #f7fafc;
    --muted: #9ba8b8;
    --line: rgba(255, 255, 255, .1);
    --primary: #117a52;
    --primary-dark: #0b5c3d;
    --accent: #e41f3d;
    --accent-blue: #173f9f;
    --accent-white: #ffffff;
    --warning: #ffb547;
    --shadow: 0 22px 60px rgba(0, 0, 0, .34);
    --glow-red: 0 0 34px rgba(228, 31, 61, .24);
    --glow-blue: 0 0 34px rgba(23, 63, 159, .22);
    --body-bg:
        radial-gradient(circle at 8% -10%, rgba(228, 31, 61, .26), transparent 30%),
        radial-gradient(circle at 100% 8%, rgba(23, 63, 159, .28), transparent 34%),
        linear-gradient(135deg, rgba(228, 31, 61, .09), transparent 23%),
        var(--bg);
    --topbar-bg: rgba(7, 10, 18, .86);
    --code-bg: #030611;
    --input-bg: rgba(3, 6, 17, .72);
    --input-focus-bg: rgba(3, 6, 17, .92);
    --subtle-bg: rgba(255, 255, 255, .08);
    --subtle-bg-hover: rgba(255, 255, 255, .14);
    --table-hover: rgba(255, 255, 255, .03);
}

html[data-theme="light"] {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --panel: rgba(255, 255, 255, .92);
    --ink: #111827;
    --muted: #5d6978;
    --line: rgba(17, 24, 39, .12);
    --shadow: 0 18px 46px rgba(17, 24, 39, .12);
    --glow-red: 0 0 26px rgba(228, 31, 61, .14);
    --glow-blue: 0 0 26px rgba(23, 63, 159, .13);
    --body-bg:
        radial-gradient(circle at 8% -10%, rgba(228, 31, 61, .14), transparent 30%),
        radial-gradient(circle at 100% 8%, rgba(23, 63, 159, .16), transparent 34%),
        linear-gradient(135deg, rgba(228, 31, 61, .06), transparent 26%),
        var(--bg);
    --topbar-bg: rgba(255, 255, 255, .88);
    --code-bg: #111827;
    --input-bg: rgba(255, 255, 255, .86);
    --input-focus-bg: #ffffff;
    --subtle-bg: rgba(17, 24, 39, .06);
    --subtle-bg-hover: rgba(17, 24, 39, .1);
    --table-hover: rgba(17, 24, 39, .035);
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--body-bg);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

code,
pre {
    font-family: Consolas, Monaco, monospace;
}

pre {
    overflow: auto;
    padding: 14px;
    color: #f7fafc;
    background: var(--code-bg);
    border-radius: 8px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 68px;
    padding: 0 28px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 10px 36px rgba(0, 0, 0, .2);
    backdrop-filter: blur(16px);
}

.topbar::before {
    content: "";
    position: absolute;
    inset: auto 0 -1px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-white), var(--accent-blue));
}

.brand {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 800;
    letter-spacing: .01em;
}

.brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .16), 0 0 24px rgba(228, 31, 61, .22);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.login-logo img {
    width: min(190px, 70%);
    height: auto;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 18px 32px rgba(0, 0, 0, .4));
}

.topbar nav {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar nav a {
    color: var(--muted);
    font-weight: 700;
}

.topbar nav a:hover {
    color: var(--accent-white);
}

html[data-theme="light"] .topbar nav a:hover {
    color: var(--accent);
}

.topbar nav a::after {
    content: "";
    display: block;
    height: 2px;
    margin-top: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-blue));
    border-radius: 999px;
    opacity: 0;
    transform: scaleX(.4);
    transition: opacity .18s ease, transform .18s ease;
}

.topbar nav a:hover::after {
    opacity: 1;
    transform: scaleX(1);
}

.theme-toggle {
    min-height: 34px;
    gap: 8px;
    padding: 0 12px;
    color: var(--ink);
    background: var(--subtle-bg);
    border: 1px solid var(--line);
    box-shadow: none;
}

.theme-toggle:hover {
    background: var(--subtle-bg-hover);
    box-shadow: none;
}

.theme-toggle-icon {
    width: 15px;
    height: 15px;
    background: var(--ink);
    border-radius: 50%;
    box-shadow: inset -5px -3px 0 var(--topbar-bg);
}

html[data-theme="light"] .theme-toggle-icon {
    background: #f6c343;
    box-shadow: 0 0 0 3px rgba(246, 195, 67, .18);
}

.container {
    width: min(1180px, calc(100% - 28px));
    margin: 28px auto 52px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: 38px 0 32px;
    border-bottom: 1px solid var(--line);
}

.hero-copy {
    display: grid;
    gap: 18px;
}

.hero h1 {
    max-width: 840px;
    margin: 0;
    font-size: clamp(2rem, 5vw, 4.2rem);
    line-height: 1;
    text-wrap: balance;
}

.hero-worldcup-logo {
    width: clamp(118px, 22vw, 210px);
    aspect-ratio: 1;
    object-fit: contain;
    background: #ffffff;
    border: 4px solid var(--accent-white);
    border-radius: 50%;
    box-shadow:
        0 0 0 4px rgba(228, 31, 61, .86),
        0 0 0 8px rgba(23, 63, 159, .82),
        0 22px 54px rgba(0, 0, 0, .38),
        var(--glow-red),
        var(--glow-blue);
}

.eyebrow {
    margin: 0;
    color: #ff526b;
    font-weight: 700;
    text-transform: uppercase;
    font-size: .8rem;
    letter-spacing: .13em;
}

.panel,
.match-card {
    position: relative;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.panel::before,
.match-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-white), var(--accent-blue));
    opacity: .86;
}

.panel {
    padding: 22px;
    margin-bottom: 22px;
}

.panel h1 {
    margin: 0 0 18px;
    font-size: 1.35rem;
}

.narrow {
    max-width: 460px;
    margin: 48px auto;
    box-shadow: var(--shadow), var(--glow-red), var(--glow-blue);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
}

.match-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.match-card {
    padding: 18px;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.match-card:hover {
    border-color: rgba(255, 255, 255, .2);
    box-shadow: var(--shadow), var(--glow-blue);
    transform: translateY(-2px);
}

.match-meta,
.score-row,
.prediction-form,
.compact-form,
.inline {
    display: flex;
    align-items: center;
}

.match-meta {
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: .88rem;
}

.score-row {
    justify-content: space-between;
    gap: 14px;
    min-height: 64px;
    font-size: 1.12rem;
}

.score-row strong {
    flex: 1 1 0;
    min-width: 0;
}

.score-row strong:last-child {
    text-align: right;
}

.versus {
    flex: 0 0 auto;
    padding: 4px 8px;
    color: #f7fafc;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(228, 31, 61, .28), rgba(23, 63, 159, .28));
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
}

.flag {
    display: inline-block;
    margin-right: 6px;
    font-size: 1.25em;
    line-height: 1;
    vertical-align: -0.08em;
}

.flag-img {
    display: inline-block;
    width: 24px;
    height: 18px;
    margin-right: 7px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 6px 14px rgba(0, 0, 0, .22);
    vertical-align: -0.22em;
}

.final-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 12px;
    color: #63d5a3;
    font-weight: 700;
    background: rgba(17, 122, 82, .18);
    border: 1px solid rgba(99, 213, 163, .18);
    border-radius: 6px;
}

.final-score span:last-child {
    color: inherit;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.final-score-exact {
    color: #63d5a3;
    background: rgba(17, 122, 82, .22);
    border-color: rgba(99, 213, 163, .3);
}

html[data-theme="light"] .final-score-exact {
    color: #047857;
    background: #e4f7ed;
    border-color: #8fd5b0;
}

.final-score-result {
    color: #8fb7ff;
    background: rgba(23, 63, 159, .24);
    border-color: rgba(143, 183, 255, .3);
}

html[data-theme="light"] .final-score-result {
    color: #1d4ed8;
    background: #e5efff;
    border-color: #93b7f4;
}

.final-score-miss {
    color: #ff7d91;
    background: rgba(228, 31, 61, .18);
    border-color: rgba(228, 31, 61, .32);
}

html[data-theme="light"] .final-score-miss {
    color: #be123c;
    background: #ffe4e9;
    border-color: #f48da0;
}

.prediction-form,
.compact-form {
    gap: 8px;
}

.stack,
.grid-form {
    display: grid;
    gap: 14px;
}

.grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-form button {
    justify-self: start;
}

label {
    display: grid;
    gap: 6px;
    color: #c5ceda;
    font-size: .9rem;
    font-weight: 700;
}

input,
select,
button,
.button {
    min-height: 40px;
    border-radius: 6px;
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 8px 10px;
    color: var(--ink);
    background: var(--input-bg);
    border: 1px solid var(--line);
    outline: 0;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:focus,
select:focus {
    background: var(--input-focus-bg);
    border-color: rgba(255, 255, 255, .38);
    box-shadow: 0 0 0 3px rgba(228, 31, 61, .16);
}

input[type="number"] {
    width: 72px;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #b91531 48%, var(--accent-blue));
    border: 0;
    box-shadow: 0 12px 26px rgba(228, 31, 61, .22);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

button:hover,
.button:hover {
    filter: brightness(1.08);
    box-shadow: 0 16px 32px rgba(23, 63, 159, .28);
    transform: translateY(-1px);
}

button:disabled,
input:disabled {
    opacity: .55;
    cursor: not-allowed;
}

html[data-theme="light"] button,
html[data-theme="light"] .button {
    background: linear-gradient(135deg, #d7193f, #a91334 48%, #1847b8);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(215, 25, 63, .22);
}

html[data-theme="light"] button:disabled,
html[data-theme="light"] input:disabled {
    opacity: 1;
}

html[data-theme="light"] button:disabled {
    color: #6b7280;
    background: #e5e7eb;
    box-shadow: none;
}

html[data-theme="light"] input:disabled {
    color: #6b7280;
    background: #f3f4f6;
}

.secondary {
    color: var(--ink);
    background: var(--subtle-bg);
    border: 1px solid var(--line);
    box-shadow: none;
}

.secondary:hover {
    background: var(--subtle-bg-hover);
}

.link-button {
    min-height: auto;
    padding: 0;
    color: var(--ink);
    background: transparent;
    box-shadow: none;
}

.link-button:hover {
    color: #ff526b;
    background: transparent;
    box-shadow: none;
    transform: none;
}

.muted {
    color: var(--muted);
    font-size: .9rem;
}

.status,
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    white-space: nowrap;
    border-radius: 999px;
}

.status {
    width: fit-content;
    padding: 10px 14px;
}

.pill {
    min-height: 28px;
    padding: 0 10px;
    font-size: .82rem;
}

.success {
    color: #63d5a3;
    background: rgba(17, 122, 82, .22);
    border: 1px solid rgba(99, 213, 163, .24);
}

html[data-theme="light"] .success {
    color: #047857;
    background: #dff7ea;
    border-color: #9ddcbb;
}

.danger {
    color: #ff7d91;
    background: rgba(228, 31, 61, .18);
    border: 1px solid rgba(228, 31, 61, .28);
}

html[data-theme="light"] .danger {
    color: #be123c;
    background: #ffe4e9;
    border-color: #f59aaa;
}

.flash {
    padding: 12px 14px;
    margin-bottom: 18px;
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.flash.ok {
    color: #63d5a3;
    background: rgba(17, 122, 82, .2);
}

html[data-theme="light"] .flash.ok {
    color: #047857;
    background: #dff7ea;
    border-color: #9ddcbb;
}

.flash.error {
    color: #ff7d91;
    background: rgba(228, 31, 61, .18);
}

html[data-theme="light"] .flash.error {
    color: #be123c;
    background: #ffe4e9;
    border-color: #f59aaa;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: .82rem;
    text-transform: uppercase;
}

tr:hover td {
    background: var(--table-hover);
}

@media (max-width: 760px) {
    .topbar,
    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        align-items: flex-start;
    }

    .topbar {
        padding: 12px 18px;
    }

    .admin-grid,
    .grid-form {
        grid-template-columns: 1fr;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}

@media (max-width: 520px) {
    .container {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero {
        gap: 14px;
    }

    .hero-worldcup-logo {
        width: 96px;
        align-self: flex-end;
    }

    .match-card {
        padding: 16px;
    }

    .match-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .score-row {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .score-row strong,
    .score-row strong:last-child {
        text-align: left;
    }

    .versus {
        align-self: flex-start;
    }

    .final-score {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}
