:root {
    --bg: #f3f8f4;
    --surface: #ffffff;
    --text: #18201c;
    --muted: #56645f;
    --line: #d8e4dd;
    --primary: #008f7a;
    --primary-dark: #006b75;
    --accent: #ff4b1f;
    --maple: #ff4b1f;
    --zayu: #9bf000;
    --clutch: #315cff;
    --purple: #5b37d6;
    --stadium: #073c5b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(49, 92, 255, .08), transparent 240px),
        linear-gradient(90deg, rgba(255, 75, 31, .08), transparent 32%, rgba(155, 240, 0, .10) 55%, rgba(49, 92, 255, .10)),
        var(--bg);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

input, button {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(16px, 4vw, 48px);
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 1px 0 rgba(0, 143, 122, .10);
    overflow: hidden;
}

.topbar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--maple), var(--zayu), var(--clutch), var(--purple));
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary), var(--clutch));
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 42%;
    transform: scale(3.2);
}

.header-flag-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    pointer-events: none;
    opacity: .16;
    filter: saturate(1.08);
}

.header-flag-bg img {
    width: 8.333%;
    min-width: 90px;
    height: 100%;
    flex: 1 0 auto;
    object-fit: cover;
    mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%);
}

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

nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    color: white;
    background: linear-gradient(135deg, var(--clutch), var(--purple));
    border-radius: 8px;
    font-weight: 700;
}

nav a:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--clutch));
}

nav a.button {
    color: white;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 28px;
    padding: 34px 0 28px;
    border-bottom: 1px solid rgba(0, 143, 122, .10);
}

.hero h1 {
    max-width: 720px;
    margin: 6px 0 10px;
    font-size: clamp(32px, 6vw, 64px);
    line-height: 1;
}

.hero p {
    max-width: 640px;
    color: var(--muted);
    font-size: 18px;
}

.hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow, .tag {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.panel, .auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 12px 32px rgba(7, 60, 91, .08);
}

.matches-panel {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .98)),
        linear-gradient(90deg, rgba(255, 75, 31, .10), rgba(155, 240, 0, .14), rgba(49, 92, 255, .10)),
        var(--surface);
}

.matches-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--maple), var(--zayu), var(--clutch));
}

.matches-panel > * {
    position: relative;
    z-index: 1;
}

.auth-card {
    width: min(420px, 100%);
    max-width: 420px;
    margin: 0;
}

.auth-page {
    display: grid;
    grid-template-columns: minmax(280px, 520px) minmax(320px, 420px);
    align-items: center;
    justify-content: center;
    gap: clamp(28px, 5vw, 72px);
    min-height: calc(100vh - 170px);
    padding: 46px 0;
}

.auth-visual {
    display: grid;
    place-items: center;
}

.auth-visual img {
    display: block;
    width: min(100%, 520px);
    height: auto;
    filter: drop-shadow(0 18px 34px rgba(7, 60, 91, .12));
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

h1, h2, h3, p {
    margin-top: 0;
}

.match-list, .predict-list, .admin-match-list {
    display: grid;
    gap: 12px;
}

.prediction-layout {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 20px;
    align-items: start;
}

.group-sidebar {
    position: sticky;
    top: 84px;
    display: grid;
    gap: 8px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(7, 60, 91, .08);
}

.group-sidebar a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    color: var(--text);
    border-radius: 8px;
    font-weight: 800;
}

.group-sidebar a:hover,
.group-sidebar a.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--clutch));
}

.group-heading {
    margin-bottom: 12px;
}

.group-heading h2 {
    margin: 4px 0 0;
    font-size: 24px;
}

.match-row, .predict-row, .result-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(255, 75, 31, .05), rgba(155, 240, 0, .05) 50%, rgba(49, 92, 255, .05)),
        rgba(255, 255, 255, .92);
}

.match-row::before,
.predict-row::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, var(--maple), var(--zayu), var(--clutch));
}

.match-row,
.predict-row {
    position: relative;
    overflow: hidden;
    min-height: 124px;
}

.match-row > *:not(.flag-watermark),
.predict-row > *:not(.flag-watermark) {
    position: relative;
    z-index: 1;
}

.flag-watermark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    opacity: .16;
    filter: saturate(1.08);
}

.flag-watermark img {
    width: 45%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.14);
}

.flag-watermark img:first-child {
    object-position: left center;
    mask-image: linear-gradient(90deg, #000 58%, transparent 100%);
}

.flag-watermark img:last-child {
    object-position: right center;
    mask-image: linear-gradient(270deg, #000 58%, transparent 100%);
}

.match-row h3, .predict-row h2 {
    margin: 5px 0;
}

.match-row p, .predict-row p, small {
    color: var(--muted);
}

.score-box {
    min-width: 130px;
    padding: 12px;
    text-align: center;
    background: linear-gradient(135deg, rgba(155, 240, 0, .18), rgba(49, 92, 255, .10));
    border-radius: 8px;
    border: 1px solid rgba(0, 143, 122, .12);
}

.score-box strong, .score-box span {
    display: block;
}

.score-box span {
    color: var(--muted);
    font-size: 13px;
}

.score-form, .result-row {
    display: flex;
    align-items: end;
    gap: 10px;
}

.score-form label {
    max-width: 120px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

input {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    color: var(--text);
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
}

input[type="number"] {
    max-width: 92px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    color: white;
    background: linear-gradient(135deg, var(--clutch), var(--purple));
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.button:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--clutch));
}

.button.secondary {
    color: white;
    background: linear-gradient(135deg, var(--clutch), var(--purple));
}

.button.danger {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.button.danger:hover {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
}

.button.small {
    min-height: 36px;
    padding: 8px 12px;
}

.button:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.notice, .error {
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 8px;
}

.notice {
    color: #12443f;
    background: linear-gradient(90deg, rgba(155, 240, 0, .24), rgba(49, 92, 255, .10));
    border: 1px solid rgba(0, 143, 122, .18);
}

.error {
    color: #7f1d1d;
    background: #fee2e2;
}

.empty {
    color: var(--muted);
}

.page-note {
    max-width: 720px;
    color: var(--muted);
}

.date-heading {
    margin: 20px 0 2px;
    padding-top: 4px;
    color: var(--primary-dark);
    font-size: 18px;
}

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

.admin-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    align-items: start;
}

.result-row {
    grid-template-columns: 1fr 80px auto 80px auto;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
}

.inline-user-form {
    margin: 0;
}

.user-create-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr)) auto auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .74);
}

.check-label {
    display: flex;
    align-items: center;
    min-height: 42px;
}

.check-label input {
    width: auto;
    min-height: auto;
}

td input {
    min-width: 150px;
}

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

    .match-row, .predict-row, .result-row, .admin-grid, .prediction-layout {
        grid-template-columns: 1fr;
    }

    .auth-page {
        grid-template-columns: 1fr;
        min-height: auto;
        padding: 32px 0;
    }

    .auth-visual img {
        width: min(100%, 360px);
    }

    .auth-card {
        margin: 0 auto;
    }

    .group-sidebar {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .score-form, .result-row {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .user-create-form {
        grid-template-columns: 1fr;
    }
}
