:root {
    color-scheme: dark;
    --bg: #121a24;
    --bg-soft: #182332;
    --panel: #202b3a;
    --panel-2: #263342;
    --text: #f4f8fb;
    --muted: #a9b8c7;
    --line: rgba(255, 255, 255, .12);
    --cyan: #28e4ff;
    --pink: #ff4ed1;
    --green: #69f0ae;
    --amber: #ffd166;
    --red: #ff6b7a;
    --shadow: 0 20px 70px rgba(0, 0, 0, .28);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(40, 228, 255, .18), transparent 34rem),
        radial-gradient(circle at 85% 8%, rgba(255, 78, 209, .14), transparent 30rem),
        linear-gradient(135deg, #131d28 0%, #1f2734 48%, #151c25 100%);
    color: var(--text);
}

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

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .06);
    color: var(--text);
    padding: .82rem .9rem;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(40, 228, 255, .8);
    box-shadow: 0 0 0 3px rgba(40, 228, 255, .12);
}

select option {
    color: #101820;
}

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

th,
td {
    padding: .9rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

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

.site-shell main,
.footer,
.topbar,
.section,
.page-head,
.download-panel,
.tutorial-content {
    width: min(1160px, calc(100% - 2rem));
    margin-inline: auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    font-weight: 800;
}

.brand-mark {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--cyan), var(--pink));
    color: #071017;
    box-shadow: 0 0 26px rgba(40, 228, 255, .25);
}

.topnav,
.hero-actions,
.head-actions,
.download-actions,
.form-actions,
.modal-actions,
.filter-row,
.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .7rem;
}

.topnav a,
.filter-chip {
    color: var(--muted);
    border: 1px solid transparent;
    padding: .65rem .85rem;
    border-radius: 999px;
}

.topnav a:hover,
.filter-chip:hover,
.filter-chip.is-active {
    color: var(--text);
    border-color: rgba(40, 228, 255, .45);
    background: rgba(40, 228, 255, .08);
}

.hero {
    min-height: clamp(420px, 68vh, 660px);
    display: grid;
    align-items: center;
    padding: clamp(3rem, 8vw, 6rem) 0;
}

.hero-compact {
    min-height: 58vh;
}

.hero-content {
    max-width: 780px;
}

.eyebrow {
    display: inline-flex;
    margin-bottom: .75rem;
    color: var(--cyan);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

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

h1 {
    font-size: clamp(2.35rem, 7vw, 5.8rem);
    line-height: .96;
    max-width: 960px;
}

h2 {
    font-size: clamp(1.45rem, 3vw, 2.3rem);
}

h3 {
    font-size: 1.1rem;
}

p {
    color: var(--muted);
    line-height: 1.7;
}

.hero p,
.page-head p {
    max-width: 720px;
    font-size: 1.08rem;
}

.btn {
    display: inline-flex;
    min-height: 2.55rem;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .72rem 1rem;
    color: var(--text);
    background: rgba(255, 255, 255, .06);
    cursor: pointer;
    text-align: center;
    white-space: normal;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: rgba(40, 228, 255, .45);
}

.btn-primary {
    border-color: rgba(40, 228, 255, .7);
    background: linear-gradient(135deg, rgba(40, 228, 255, .95), rgba(105, 240, 174, .88));
    color: #061017;
    box-shadow: 0 0 32px rgba(40, 228, 255, .28);
    font-weight: 800;
}

.btn-secondary {
    border-color: rgba(255, 78, 209, .62);
    background: rgba(255, 78, 209, .12);
}

.btn-ghost {
    background: rgba(255, 255, 255, .05);
}

.btn-card {
    width: 100%;
    margin-top: auto;
    border-color: rgba(40, 228, 255, .4);
}

.btn-small {
    min-height: 2rem;
    padding: .45rem .7rem;
    font-size: .9rem;
}

.btn-danger {
    border-color: rgba(255, 107, 122, .7);
    background: rgba(255, 107, 122, .15);
    color: #ffdfe4;
}

.section {
    padding: 2.3rem 0;
}

.section-tight {
    padding-top: .8rem;
}

.section-heading,
.page-head,
.panel-heading,
.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.section-heading.inline {
    align-items: center;
}

.game-grid,
.version-grid,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.game-card,
.version-card,
.admin-card,
.download-panel,
.tutorial-content,
.empty-state,
.stat-card,
.auth-card,
.download-modal-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .045));
    box-shadow: var(--shadow);
}

.game-card,
.version-card {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
}

.game-card {
    border-color: rgba(105, 240, 174, .26);
}

.game-card:hover,
.version-card:hover {
    border-color: rgba(40, 228, 255, .55);
}

.game-card-kicker,
.muted,
.table-sub {
    color: var(--muted);
}

.game-card strong {
    margin: .8rem 0 .35rem;
    font-size: 1.4rem;
}

.version-card h2,
.version-card h3 {
    margin-bottom: .55rem;
}

.card-topline,
.card-meta {
    display: flex;
    justify-content: space-between;
    gap: .7rem;
    flex-wrap: wrap;
    margin-bottom: .9rem;
}

.card-meta {
    margin-top: auto;
    color: var(--muted);
    font-size: .92rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: .25rem .55rem;
    font-size: .78rem;
    font-weight: 800;
}

.badge-game {
    background: rgba(40, 228, 255, .12);
    color: var(--cyan);
}

.badge-required {
    background: rgba(105, 240, 174, .12);
    color: var(--green);
}

.badge-optional {
    background: rgba(255, 209, 102, .13);
    color: var(--amber);
}

.empty-state {
    padding: 1.3rem;
}

.empty-state.compact {
    box-shadow: none;
}

.page-head {
    align-items: center;
    padding: 2.2rem 0 1rem;
}

.download-panel {
    padding: 1.2rem;
    margin-bottom: 2rem;
}

.download-list {
    display: grid;
    gap: .85rem;
}

.quick-select-row {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-bottom: 1rem;
}

.category-select-panel {
    display: grid;
    gap: .75rem;
    margin-bottom: 1rem;
    padding: .9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(18, 26, 36, .45);
}

.category-select-title {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 800;
    text-transform: uppercase;
}

.category-select-list {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem .9rem;
}

.category-check {
    padding: .45rem .65rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .05);
}

.download-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(18, 26, 36, .55);
}

.download-order {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    border-radius: 8px;
    color: #071017;
    background: var(--cyan);
    font-weight: 900;
}

.download-titleline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
    flex-wrap: wrap;
}

.link-category-row {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin: .35rem 0 .85rem;
}

.checkline {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: var(--text);
}

.checkline input {
    width: 1rem;
    min-width: 1rem;
}

.download-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(4, 8, 12, .76);
    backdrop-filter: blur(10px);
}

.download-modal[hidden] {
    display: none;
}

.download-modal-card {
    position: relative;
    width: min(520px, 100%);
    padding: 1.4rem;
}

.modal-close {
    position: absolute;
    top: .8rem;
    right: .8rem;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    color: var(--text);
    cursor: pointer;
}

.tutorial-content {
    padding: clamp(1rem, 3vw, 2rem);
    margin-bottom: 2rem;
}

.tutorial-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.tutorial-content a {
    color: var(--cyan);
    text-decoration: underline;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    padding: 2rem 0;
    border-top: 1px solid var(--line);
}

.flash {
    width: min(920px, calc(100% - 2rem));
    margin: .8rem auto;
    padding: .85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .08);
}

.flash-success {
    border-color: rgba(105, 240, 174, .42);
}

.flash-error,
.flash-warning {
    border-color: rgba(255, 107, 122, .5);
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1rem;
    border-right: 1px solid var(--line);
    background: rgba(18, 26, 36, .82);
}

.admin-brand {
    margin-bottom: 1.5rem;
}

.admin-nav,
.logout-form {
    display: grid;
    gap: .55rem;
}

.admin-nav a {
    border-radius: 8px;
    padding: .78rem .85rem;
    color: var(--muted);
}

.admin-nav a:hover,
.admin-nav a.is-active {
    color: var(--text);
    background: rgba(40, 228, 255, .08);
}

.logout-form {
    margin-top: 2rem;
}

.admin-main {
    width: min(1280px, 100%);
    padding: 1.5rem;
}

.admin-card,
.stat-card {
    padding: 1.1rem;
}

.admin-card.narrow {
    max-width: 760px;
}

.admin-section {
    margin-top: 1.5rem;
}

.stats-grid {
    margin-bottom: 1.5rem;
}

.stat-card span {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: .45rem;
    font-size: 2.2rem;
}

.admin-grid-two {
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    gap: 1rem;
}

.admin-stack {
    display: grid;
    gap: 1rem;
}

.form-stack,
.form-grid {
    display: grid;
    gap: .9rem;
}

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

.form-grid.mini {
    gap: .65rem;
}

.form-grid .full {
    grid-column: 1 / -1;
}

label span,
legend {
    display: block;
    margin-bottom: .35rem;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
}

fieldset {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .65rem;
}

.danger-zone {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

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

.bulk-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: .75rem;
}

.checkline.compact {
    gap: .35rem;
    font-size: .82rem;
}

.table-sub {
    display: block;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .86rem;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(440px, 100%);
    padding: 1.5rem;
}

.auth-brand {
    margin-bottom: 1.5rem;
}

.rich-form {
    gap: 0;
}

.rich-toolbar {
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: rgba(255, 255, 255, .08);
}

.rich-editor {
    min-height: 420px;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: rgba(255, 255, 255, .04);
}

.ql-toolbar.ql-snow,
.ql-container.ql-snow {
    border-color: var(--line);
}

.ql-snow .ql-stroke {
    stroke: var(--text);
}

.ql-snow .ql-fill {
    fill: var(--text);
}

.ql-snow .ql-picker {
    color: var(--text);
}

.ql-editor {
    min-height: 420px;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.7;
}

.ql-editor.ql-blank::before {
    color: var(--muted);
}

.ql-tooltip {
    z-index: 20;
}

@media (max-width: 860px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: relative;
        height: auto;
    }

    .admin-main {
        padding: 1rem;
    }

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

    .page-head,
    .panel-heading,
    .admin-head,
    .section-heading,
    .footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: clamp(2.1rem, 12vw, 3.4rem);
    }
}

@media (max-width: 560px) {
    .site-shell main,
    .footer,
    .topbar,
    .section,
    .page-head,
    .download-panel,
    .tutorial-content {
        width: min(100% - 1rem, 1160px);
    }

    .download-item {
        grid-template-columns: 1fr;
    }

    .download-order {
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    .table-actions,
    .head-actions {
        width: 100%;
    }
}
