:root {
  color-scheme: dark;
  --bg: #090b0d;
  --panel: #101418;
  --panel-raised: #151a1f;
  --line: #273038;
  --text: #f3f6f7;
  --muted: #91a0aa;
  --accent: #69ef9a;
  --accent-soft: rgba(105, 239, 154, .12);
  --warn: #f3bc62;
  --danger: #ef7777;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); background: radial-gradient(circle at 72% -20%, rgba(105,239,154,.1), transparent 34rem), var(--bg); min-height: 100vh; }
button, input, select { font: inherit; }
button, select, input { color: inherit; }

.site-header { min-height: 72px; padding: 0 clamp(20px, 5vw, 72px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: var(--text); text-decoration: none; font-weight: 780; letter-spacing: .13em; font-size: .82rem; display: inline-flex; align-items: center; gap: 11px; }
.pulse-mark { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 22px rgba(105,239,154,.7); }
.header-meta { display: flex; align-items: center; gap: 24px; color: var(--muted); font-size: .78rem; }
.live-indicator { display: inline-flex; gap: 8px; align-items: center; color: #c5d0d5; }
.live-indicator > span:first-child { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.language-control select { height: 34px; min-width: 66px; color: #c8d1d6; background: #0d1013; border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; font: 700 .7rem ui-monospace, monospace; cursor: pointer; }
.language-control select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { width: min(1420px, calc(100% - 40px)); margin: 0 auto; }
.hero { padding: clamp(72px, 10vw, 148px) 0 clamp(64px, 9vw, 120px); display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: clamp(40px, 8vw, 130px); align-items: end; }
.eyebrow { margin: 0 0 18px; color: var(--accent); text-transform: uppercase; letter-spacing: .16em; font-weight: 730; font-size: .71rem; }
h1 { margin: 0; font-size: clamp(3.2rem, 7.4vw, 7.6rem); letter-spacing: -.065em; line-height: .91; font-weight: 760; }
h1 span { color: #77858d; }
h1 .game-name { color: inherit; }
.intro { color: #aab5bb; font-size: clamp(1rem, 1.4vw, 1.22rem); max-width: 680px; line-height: 1.6; margin: 32px 0 0; }
.metrics { margin: 0; border-top: 1px solid var(--line); }
.metrics div { display: flex; align-items: baseline; justify-content: space-between; padding: 21px 0; border-bottom: 1px solid var(--line); }
.metrics dt { color: var(--muted); font-size: .82rem; }
.metrics dd { margin: 0; font-size: 2.1rem; letter-spacing: -.05em; font-weight: 680; font-variant-numeric: tabular-nums; }

.directory { padding-bottom: 80px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 28px; }
h2 { margin: 0; font-size: clamp(2rem, 3vw, 3.25rem); letter-spacing: -.045em; }
.refresh-button, .load-more { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 10px 17px; cursor: pointer; }
.refresh-button:hover, .load-more:hover { border-color: var(--accent); color: var(--accent); }
.refresh-button:focus-visible, .load-more:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.filters { padding: 16px; border: 1px solid var(--line); background: rgba(16,20,24,.86); border-radius: var(--radius); display: grid; grid-template-columns: minmax(240px, 1fr) repeat(4, minmax(125px, 160px)) auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.filters.openttd-filters { grid-template-columns: minmax(240px, 1.4fr) repeat(4, minmax(125px, 1fr)); }
.filters label:not(.checkbox-field) { display: grid; gap: 7px; color: var(--muted); font-size: .72rem; }
.filters input, .filters select { width: 100%; height: 42px; border: 1px solid #303a42; background: #0c0f12; border-radius: 8px; padding: 0 12px; }
.search-field input { font-size: .92rem; }
.checkbox-field { height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 10px; color: #c6d0d5; font-size: .82rem; white-space: nowrap; }
.checkbox-field input { accent-color: var(--accent); width: 16px; height: 16px; }
.notice { min-height: 42px; display: flex; align-items: center; color: var(--muted); font-size: .84rem; }
.notice.error { color: var(--danger); }

.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(16,20,24,.72); }
.list-hint { margin: -4px 0 14px; color: #7f8d95; font-size: .76rem; text-align: right; }
.list-hint span:last-child { color: var(--accent); }
table { width: 100%; min-width: 1370px; border-collapse: collapse; }
th { padding: 14px 18px; color: #71808a; font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; text-align: left; font-weight: 720; border-bottom: 1px solid var(--line); }
.sort-button { display: inline-flex; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.sort-button:hover, .sort-button:focus-visible, th.sort-active .sort-button { color: var(--text); }
.sort-button:focus-visible { outline: 1px solid var(--accent); outline-offset: 5px; }
.sort-indicator { color: #4f5c64; font-size: .72rem; }
th.sort-active .sort-indicator { color: var(--accent); }
td { padding: 18px; border-bottom: 1px solid rgba(39,48,56,.72); color: #c7d1d6; font-size: .86rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.server-name { display: block; color: var(--text); text-decoration: none; font-weight: 650; max-width: 470px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server-name:hover { color: var(--accent); }
.server-title-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.server-title-line .server-name { min-width: 0; }
.server-meta { display: flex; align-items: center; gap: 7px; margin-top: 5px; padding-left: 29px; }
.country-flag { display: block; width: 20px; height: 15px; flex: 0 0 20px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,.13); }
.server-address { color: #6f7d85; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; }
.server-tags { color: #8fa0a9; font-size: .68rem; }
.playstyle-badge { display: inline-flex; align-items: center; min-width: 48px; justify-content: center; padding: 5px 8px; border: 1px solid #34414a; border-radius: 999px; color: #aebac0; font: 750 .67rem ui-monospace, monospace; letter-spacing: .05em; }
.playstyle-badge.pve { color: #78eaa3; border-color: rgba(105,239,154,.35); background: rgba(105,239,154,.07); }
.playstyle-badge.pvp { color: #ff8b8b; border-color: rgba(239,119,119,.38); background: rgba(239,119,119,.07); }
.playstyle-badge.pvpve { color: #f1bd67; border-color: rgba(243,188,98,.38); background: rgba(243,188,98,.07); }
.sparkline { width: 126px; height: 34px; color: var(--muted); }
.sparkline svg { display: block; width: 126px; height: 34px; overflow: visible; }
.sparkline polygon { fill: rgba(105,239,154,.08); }
.sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.sparkline.empty { display: grid; place-items: center; color: #59666e; }
.sparkline-cell { width: 154px; }
.status { display: inline-flex; align-items: center; gap: 7px; text-transform: capitalize; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.online::before { background: var(--accent); box-shadow: 0 0 12px rgba(105,239,154,.5); }
.status.degraded::before { background: var(--warn); }
.status.offline::before { background: var(--danger); }
.players, .ping { font-variant-numeric: tabular-nums; }
.list-rank { min-width: 90px; font-variant-numeric: tabular-nums; }
.list-rank strong, .list-rank small { display: block; }
.list-rank strong { color: var(--text); font-size: .95rem; }
.list-rank small { margin-top: 4px; font-size: .72rem; font-weight: 700; }
.list-rank .rank-up { color: var(--accent); }
.list-rank .rank-down { color: var(--danger); }
.list-rank .rank-same { color: var(--muted); }
.population-status { color: #d5a956 !important; font-weight: 700; letter-spacing: 0; }
.population-status.flagged { color: var(--danger) !important; }
.population-status.verified:empty { display: none; }
.connect { color: var(--accent); text-decoration: none; padding: 8px 12px; border-radius: 7px; background: var(--accent-soft); white-space: nowrap; }
.connect:hover { background: rgba(105,239,154,.2); }
.empty-row td { text-align: center; padding: 64px 20px; color: var(--muted); }
.load-more { display: block; margin: 22px auto 0; }
.load-more[hidden] { display: none; }

footer { width: min(1420px, calc(100% - 40px)); margin: 0 auto; border-top: 1px solid var(--line); padding: 28px 0 48px; color: #65727a; display: flex; justify-content: space-between; gap: 28px; font-size: .75rem; line-height: 1.5; }
footer p { margin: 0; max-width: 700px; }
.footer-link { color: inherit; }
.footer-link:hover { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.detail-main { padding: 54px 0 90px; }
.detail-loading { min-height: 55vh; display: grid; place-items: center; color: var(--muted); }
.detail-loading.error { color: var(--danger); }
.back-link { color: var(--muted); text-decoration: none; font-size: .82rem; }
.back-link:hover { color: var(--accent); }
.detail-title-row { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 42px 0 34px; }
.detail-title { max-width: 1050px; font-size: clamp(2.2rem, 5vw, 5.2rem); line-height: .98; overflow-wrap: anywhere; }
.detail-status-line { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: .78rem; margin-bottom: 18px; }
.detail-address { margin: 18px 0 0; color: #7d8a92; font: .82rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.detail-connect { padding: 12px 19px; margin-bottom: 3px; }
.rank-strip { display: grid; grid-template-columns: 1.15fr repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: rgba(16,20,24,.82); }
.rank-strip > div { min-height: 116px; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; border-right: 1px solid var(--line); }
.rank-strip > div:last-child { border-right: 0; }
.rank-strip span, .rank-strip small { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.rank-strip strong { font-size: clamp(1.35rem, 2.2vw, 2.1rem); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.rank-strip .rank-up { color: var(--accent); }
.rank-strip .rank-down { color: var(--danger); }
.detail-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.info-card, .chart-card { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(16,20,24,.72); }
.info-card { padding: 28px; }
.info-card h2 { font-size: 1.7rem; margin-bottom: 24px; }
.detail-list { margin: 0; }
.detail-list div { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 1.2fr); gap: 20px; padding: 13px 0; border-top: 1px solid rgba(39,48,56,.75); }
.detail-list dt { color: var(--muted); font-size: .75rem; }
.detail-list dd { margin: 0; color: #d5dde1; text-align: right; overflow-wrap: anywhere; font-size: .82rem; }
.history-section { padding-top: 74px; }
.history-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.range-picker { display: inline-flex; border: 1px solid var(--line); padding: 4px; border-radius: 999px; background: #0c0f12; }
.range-picker button { min-width: 54px; border: 0; border-radius: 999px; padding: 8px 12px; background: transparent; color: var(--muted); cursor: pointer; font-size: .72rem; font-weight: 700; }
.range-picker button.active { color: #07100a; background: var(--accent); }
.range-picker button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { min-width: 0; padding: 22px; }
.chart-card h3 { margin: 0 0 10px; font-size: 1rem; }
.chart { min-height: 280px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid-line { stroke: #283139; stroke-width: 1; }
.chart-axis-label { fill: #6f7d85; font-size: 10px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.chart-legend { display: flex; gap: 16px; padding: 4px 0 0 48px; color: var(--muted); font-size: .7rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--series-color); }
.chart-empty { min-height: 240px; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.embed-section { padding-top: 74px; }
.embed-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; }
.embed-heading h2 { margin-bottom: 10px; }
.embed-heading p:not(.eyebrow) { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.65; }
.embed-heading label { min-width: 210px; color: var(--muted); font-size: .72rem; }
.embed-heading label span { display: block; margin-bottom: 7px; }
.embed-heading select { width: 100%; }
.embed-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; margin-top: 22px; }
.banner-preview-shell, .embed-code { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(16,20,24,.72); padding: 24px; }
.banner-preview-shell { min-height: 300px; display: grid; place-items: center; overflow: auto; background-image: linear-gradient(45deg, rgba(255,255,255,.015) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.015) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.015) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.015) 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
.banner-preview-shell a { display: block; line-height: 0; }
.banner-preview-shell img { display: block; max-width: 100%; height: auto; }
.embed-code { display: flex; flex-direction: column; gap: 10px; }
.embed-code label { color: var(--muted); font-size: .72rem; }
.embed-code textarea { width: 100%; flex: 1; min-height: 150px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; background: #090c0e; color: #aebbc2; padding: 13px; font: .72rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.embed-code button { align-self: flex-start; }

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .metrics { max-width: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .rank-strip { grid-template-columns: 1fr 1fr; }
  .rank-strip > div { border-bottom: 1px solid var(--line); }
  .rank-strip > div:nth-child(2n) { border-right: 0; }
  .detail-info-grid, .chart-grid, .embed-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  main, footer { width: min(100% - 28px, 1420px); }
  .site-header { padding: 0 14px; }
  #last-updated { display: none; }
  .header-meta { gap: 12px; }
  .hero { padding-top: 64px; }
  h1 { font-size: clamp(3rem, 16vw, 5rem); }
  .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .section-heading { align-items: center; }
  footer { flex-direction: column; }
  .detail-main { padding-top: 32px; }
  .detail-title-row, .history-heading, .embed-heading { align-items: flex-start; flex-direction: column; }
  .detail-title { font-size: 2.4rem; }
  .rank-strip { grid-template-columns: 1fr; }
  .rank-strip > div { min-height: 92px; border-right: 0; }
  .detail-list div { grid-template-columns: 1fr; gap: 5px; }
  .detail-list dd { text-align: left; }
  .range-picker { width: 100%; }
  .range-picker button { flex: 1; }
  .chart-card { padding: 16px 10px; }
  .embed-heading label { width: 100%; }
  .banner-preview-shell, .embed-code { padding: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .pulse-mark { animation: pulse 2.8s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 30px rgba(105,239,154,.9); transform: scale(1.08); } }
}
