:root {
    color-scheme: light;
    --bg: #f7f6f2;
    --bg-soft: #fbfaf7;
    --surface: #ffffff;
    --surface-muted: #f1efea;
    --ink: #171815;
    --ink-soft: #343832;
    --muted: #686d64;
    --faint: #8a8f86;
    --border: #dedbd2;
    --border-strong: #c9c4b8;
    --accent: #0f766e;
    --accent-strong: #0b5d56;
    --accent-soft: #e3f3f0;
    --good: #087f5b;
    --warn: #946200;
    --danger: #b42318;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(20, 24, 18, 0.06);
    --shadow-md: 0 18px 44px rgba(20, 24, 18, 0.08);
    --page-glow: rgba(255, 255, 255, 0.7);
    --header-bg: rgba(251, 250, 247, 0.9);
    --header-border: rgba(222, 219, 210, 0.86);
    --glass: rgba(255, 255, 255, 0.78);
    --panel-bg: rgba(255, 255, 255, 0.86);
    --card-bg: rgba(255, 255, 255, 0.88);
    --chart-previous: rgba(104, 109, 100, 0.58);
    --chart-grid: rgba(23, 24, 21, 0.09);
    --button-bg: #171815;
    --button-bg-hover: #343832;
    --button-ink: #ffffff;
    --nav-active-bg: #171815;
    --nav-active-ink: #ffffff;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #10110f;
    --bg-soft: #151713;
    --surface: #1a1c18;
    --surface-muted: #22251f;
    --ink: #f4f1ea;
    --ink-soft: #dedacf;
    --muted: #aaa79e;
    --faint: #83877d;
    --border: #34382f;
    --border-strong: #4b5145;
    --accent: #5eead4;
    --accent-strong: #8deee3;
    --accent-soft: #173c38;
    --good: #4ade80;
    --warn: #f2c94c;
    --danger: #ff7a70;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.34);
    --page-glow: rgba(255, 255, 255, 0.035);
    --header-bg: rgba(18, 20, 17, 0.9);
    --header-border: rgba(52, 56, 47, 0.86);
    --glass: rgba(26, 28, 24, 0.78);
    --panel-bg: rgba(26, 28, 24, 0.86);
    --card-bg: rgba(26, 28, 24, 0.88);
    --chart-previous: rgba(170, 167, 158, 0.5);
    --chart-grid: rgba(244, 241, 234, 0.1);
    --button-bg: #f4f1ea;
    --button-bg-hover: #dedacf;
    --button-ink: #10110f;
    --nav-active-bg: #f4f1ea;
    --nav-active-ink: #10110f;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #10110f;
        --bg-soft: #151713;
        --surface: #1a1c18;
        --surface-muted: #22251f;
        --ink: #f4f1ea;
        --ink-soft: #dedacf;
        --muted: #aaa79e;
        --faint: #83877d;
        --border: #34382f;
        --border-strong: #4b5145;
        --accent: #5eead4;
        --accent-strong: #8deee3;
        --accent-soft: #173c38;
        --good: #4ade80;
        --warn: #f2c94c;
        --danger: #ff7a70;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
        --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.34);
        --page-glow: rgba(255, 255, 255, 0.035);
        --header-bg: rgba(18, 20, 17, 0.9);
        --header-border: rgba(52, 56, 47, 0.86);
        --glass: rgba(26, 28, 24, 0.78);
        --panel-bg: rgba(26, 28, 24, 0.86);
        --card-bg: rgba(26, 28, 24, 0.88);
        --chart-previous: rgba(170, 167, 158, 0.5);
        --chart-grid: rgba(244, 241, 234, 0.1);
        --button-bg: #f4f1ea;
        --button-bg-hover: #dedacf;
        --button-ink: #10110f;
        --nav-active-bg: #f4f1ea;
        --nav-active-ink: #10110f;
    }
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    background:
        linear-gradient(180deg, var(--page-glow), rgba(255,255,255,0) 260px),
        var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

img,
svg,
canvas {
    max-width: 100%;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration: underline;
}

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

.siteHeader {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    backdrop-filter: blur(18px);
}

.siteHeaderRow {
    width: min(1240px, calc(100% - 32px));
    min-height: 74px;
    margin: 0 auto;
    padding: 12px 0;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.logoLink {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
    color: var(--ink);
    flex: 0 0 auto;
}

.logoLink:hover {
    text-decoration: none;
}

.logoImg {
    display: block;
    width: 190px;
    height: 44px;
    max-width: 42vw;
    object-fit: cover;
    object-position: center;
    opacity: 0.96;
}

.navToggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.navToggle:hover {
    background: var(--surface-muted);
}

.navLinks {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 4px;
    border: 1px solid var(--header-border);
    border-radius: 999px;
    background: var(--glass);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

.navLinks a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}

.navLinks a:hover {
    background: var(--surface-muted);
    color: var(--ink);
    text-decoration: none;
}

.navLinks a.active {
    background: var(--nav-active-bg);
    border-color: var(--nav-active-bg);
    color: var(--nav-active-ink);
}

.headerRight {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-left: auto;
    min-width: min(100%, 260px);
}

.headerRight .muted {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--glass);
    color: var(--muted);
    white-space: nowrap;
}

.searchGroup {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    width: 100%;
}

.themeControl {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 2px;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--glass);
    box-shadow: var(--shadow-sm);
}

.themeButton,
.siteHeader button.themeButton:not(.navToggle) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 9px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    font-size: 12px;
    font-weight: 700;
}

.themeButton:hover,
.siteHeader button.themeButton:not(.navToggle):hover {
    background: var(--surface-muted);
    color: var(--ink);
}

.themeButton.active,
.siteHeader button.themeButton.active:not(.navToggle) {
    background: var(--nav-active-bg);
    color: var(--nav-active-ink);
}

.siteHeader input[type="text"],
.siteHeader input:not([type]) {
    width: 100%;
    max-width: 420px;
}

.wrap {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 72px;
}

.muted {
    color: var(--muted);
    opacity: 1;
}

.mono {
    font-family: var(--mono);
}

h1,
h2,
h3 {
    color: var(--ink);
    letter-spacing: 0;
}

h2 {
    margin: 0 0 18px;
    font-size: 28px;
    line-height: 1.15;
}

input[type="text"],
input:not([type]),
input[type="number"],
input[type="search"],
select {
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    outline: none;
    box-shadow: var(--shadow-sm);
}

input::placeholder {
    color: var(--faint);
}

input:focus,
select:focus {
    border-color: rgba(15, 118, 110, 0.58);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

button,
.btn,
.copyBtn,
.linkBtn {
    min-height: 40px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--button-bg);
    color: var(--button-ink);
    cursor: pointer;
    font-weight: 650;
    line-height: 1.2;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

button:hover,
.btn:hover,
.copyBtn:hover,
.linkBtn:hover {
    background: var(--button-bg-hover);
    text-decoration: none;
}

.searchGroup button,
.siteHeader button:not(.navToggle) {
    background: var(--button-bg);
    border-color: var(--button-bg);
    color: var(--button-ink);
}

.searchGroup button:hover,
.siteHeader button:not(.navToggle):hover {
    background: var(--button-bg-hover);
}

.toolbar .btn,
.pager .btn,
.filters .btn,
.copyBtn,
.linkBtn,
.chip {
    background: var(--surface);
    color: var(--ink);
}

.toolbar .btn.active,
.pager .btn.active {
    background: var(--accent-soft);
    border-color: rgba(15, 118, 110, 0.28);
    color: var(--accent-strong);
}

.pill,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.grid {
    gap: 16px;
}

.card,
a.card,
.profile,
.marketSide,
.historyBox,
.tableWrap,
.flagCard,
.filters {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-bg);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

a.card {
    color: var(--ink);
    text-decoration: none;
}

.card:hover,
a.card:hover {
    border-color: var(--border-strong);
    background: var(--surface);
    transform: none;
    text-decoration: none;
}

.cardTitle,
.title,
.nameRow {
    color: var(--ink);
}

.cardDesc,
.meta,
.kv {
    color: var(--muted);
    opacity: 1;
}

.dot {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.dot.online {
    background: var(--good);
}

.good,
.profit {
    color: var(--good);
}

.warn {
    color: var(--warn);
}

table {
    color: var(--ink);
}

th,
td {
    border-bottom-color: var(--border);
}

th {
    background: var(--bg-soft);
    color: var(--muted);
    opacity: 1;
    font-weight: 650;
}

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

canvas {
    border-radius: var(--radius);
}

.alert {
    top: auto;
    bottom: 18px;
    width: min(520px, calc(100% - 28px));
    justify-content: space-between;
    border-color: rgba(180, 35, 24, 0.28);
    background: color-mix(in srgb, var(--danger) 11%, var(--surface));
    color: var(--danger);
    box-shadow: var(--shadow-md);
}

.alert strong,
.alert button {
    color: var(--danger);
}

.alert button,
.alert button:hover {
    min-height: auto;
    padding: 0 2px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.historyRow,
.listings,
.routeCell div,
.playerItem,
.residentRow,
.row {
    border-color: var(--border);
}

.homeShell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 76px;
}

.homeIntro {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    align-items: end;
    padding: 18px 0 34px;
    border-bottom: 1px solid var(--border);
}

.homeEyebrow {
    margin-bottom: 14px;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 750;
}

.homeTitle {
    max-width: 760px;
    margin: 0;
    color: var(--ink);
    font-size: 56px;
    line-height: 1.02;
    letter-spacing: 0;
}

.homeCopy {
    max-width: 640px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.65;
}

.homePulse {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: stretch;
    margin: 24px 0 34px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-bg);
    box-shadow: var(--shadow-sm);
}

.homePulseHeader {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.homePulseHeader h2 {
    margin: 0;
}

.homePulseHeader p {
    max-width: 560px;
    margin: 6px 0 0;
    color: var(--muted);
}

.homePulseStatus {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.playerChartFrame {
    min-height: 286px;
}

.playerChartCanvas {
    display: block;
    width: 100%;
    height: 260px;
}

.playerChartLegend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.legendItem {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.legendSwatch {
    width: 24px;
    height: 2px;
    border-radius: 999px;
    background: var(--accent);
}

.legendSwatch.previous {
    background: var(--chart-previous);
}

.homePulseStats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.homePulseStat {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.homePulseStat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.homePulseStat strong {
    display: block;
    margin-top: 5px;
    color: var(--ink);
    font-size: 24px;
    line-height: 1.1;
}

.homeSectionHeader {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 30px 0 16px;
}

.homeSectionHeader h2 {
    margin: 0;
}

.homeSectionHeader p {
    max-width: 520px;
    margin: 0;
    color: var(--muted);
}

.homeGrid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.sectionCard {
    display: flex;
    flex-direction: column;
    min-height: 178px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    cursor: pointer;
}

.sectionCard:hover {
    border-color: var(--border-strong);
    background: var(--surface);
    text-decoration: none;
}

.sectionCardKicker {
    margin-bottom: 18px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 750;
}

.sectionCard h3 {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.25;
}

.sectionCard p {
    margin: 0;
    color: var(--muted);
}

.sectionCardFooter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 22px;
    color: var(--faint);
    font-size: 13px;
}

.sectionCardAction {
    color: var(--accent-strong);
    font-weight: 750;
}

@media (max-width: 1180px) {
    .siteHeaderRow {
        align-items: flex-start;
    }

    .navLinks {
        order: 3;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .navLinks::-webkit-scrollbar {
        display: none;
    }

    .headerRight {
        align-self: center;
    }

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

    .homePulse {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 900px) {
    .siteHeaderRow {
        width: min(100% - 28px, 1240px);
        min-height: 62px;
        align-items: center;
        gap: 10px;
    }

    .logoImg {
        width: 168px;
        height: 38px;
        max-width: 58vw;
    }

    .navToggle {
        display: inline-flex;
    }

    .navLinks {
        order: 3;
        display: none;
        width: 100%;
        padding: 6px;
        border-radius: 12px;
        background: var(--surface);
        box-shadow: var(--shadow-sm);
        overflow: visible;
    }

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

    .navLinks a {
        justify-content: flex-start;
        min-height: 40px;
        padding: 0 12px;
        border-radius: var(--radius);
    }

    .headerRight {
        order: 4;
        width: 100%;
        min-width: 0;
        margin-left: 0;
        justify-content: stretch;
    }

    .searchGroup,
    .headerRight .searchGroup {
        justify-content: stretch;
        width: 100%;
    }

    .siteHeader input[type="text"],
    .siteHeader input:not([type]) {
        max-width: none;
    }

    .wrap,
    .homeShell {
        width: min(100% - 28px, 1240px);
        padding-top: 26px;
    }

    .homeIntro {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .homeTitle {
        font-size: 40px;
    }

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

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

    .homeSectionHeader {
        display: block;
    }

    .homeSectionHeader p {
        margin-top: 8px;
    }
}

@media (max-width: 560px) {
    body {
        font-size: 13px;
    }

    .homeTitle {
        font-size: 32px;
        line-height: 1.08;
    }

    .homeCopy {
        font-size: 15px;
    }

    .navLinks.open,
    .homeGrid {
        grid-template-columns: 1fr;
    }

    .searchGroup {
        flex-wrap: wrap;
    }

    .themeControl {
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .themeButton,
    .siteHeader button.themeButton:not(.navToggle) {
        justify-content: center;
    }

    .homePulse {
        padding: 14px;
    }

    .homePulseHeader {
        display: block;
    }

    .homePulseStatus {
        margin-top: 8px;
        white-space: normal;
    }

    .playerChartCanvas {
        height: 230px;
    }

    .searchGroup input,
    .searchGroup button {
        width: 100%;
    }

    .sectionCard {
        min-height: 154px;
    }

    .homePulseStats {
        grid-template-columns: 1fr;
    }
}
