:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f1f6fb; --panel: #fff; --surface: #e7eef7; --ink: #18283e;
  --muted: #52647b; --line: #c0cfe0; --accent: #245edb;
  --accent-text: #224eaf; --soft: #e2edff; --selected: #3f6dc4;
  --shadow: #153b6714; --hover: #d6e5fb; --online: #18734f; --offline: #a54349;
  --help-soft: #ffe6e9; --help-ink: #a83549; --help-line: #e5b4bd; --help-hover: #ffdae0;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #20262f; --panel: #303946; --surface: #3e4959; --ink: #f4f7fb;
  --muted: #c2cddc; --line: #617087; --accent: #286bda;
  --accent-text: #c1ddff; --soft: #2c527b; --selected: #8bbfff;
  --shadow: #0000002b; --hover: #386894; --online: #82dab1; --offline: #f1a2a8;
  --help-soft: #684c57; --help-ink: #ffe0e5; --help-line: #aa7886; --help-hover: #795b67;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #20262f; --panel: #303946; --surface: #3e4959; --ink: #f4f7fb;
    --muted: #c2cddc; --line: #617087; --accent: #286bda;
    --accent-text: #c1ddff; --soft: #2c527b; --selected: #8bbfff;
    --shadow: #0000002b; --hover: #386894; --online: #82dab1; --offline: #f1a2a8;
    --help-soft: #684c57; --help-ink: #ffe0e5; --help-line: #aa7886; --help-hover: #795b67;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent-text); text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, summary:focus-visible, .address:focus-visible { outline: 3px solid var(--selected); outline-offset: 3px; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.site-header { background: var(--panel); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); padding-top: max(env(safe-area-inset-top, 0px), var(--tg-top, 0px)); }
.header-inner, main { max-width: 860px; margin: 0 auto; padding-left: 20px; padding-right: 20px; padding-left: max(20px, env(safe-area-inset-left, 0px), var(--tg-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px), var(--tg-right, 0px)); }
.header-inner { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-size: 21px; font-weight: 850; letter-spacing: -1px; }
.brand span { color: var(--accent-text); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; padding: 0; background: transparent; color: var(--accent-text); border: 1px solid transparent; border-radius: 12px; }
.theme-sun, :root[data-theme=dark] .theme-moon { display: none; }
:root[data-theme=dark] .theme-sun { display: block; }
main { padding-top: 28px; padding-bottom: 36px; padding-bottom: max(36px, env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px)); }
.page-heading { display: flex; align-items: center; gap: 10px; }
h1 { font-size: clamp(24px, 4vw, 30px); line-height: 1.2; letter-spacing: -.5px; margin: 0; }
.server-count { padding: 2px 9px; background: var(--surface); border-radius: 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.platform-hint { color: var(--muted); margin: 10px 0 0; font-size: 14px; }
.connection-notice { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--help-line); border-radius: 16px; background: var(--help-soft); color: var(--help-ink); }
.connection-notice h2 { font-size: 16px; line-height: 1.4; }
.connection-notice p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; }
.connection-notice-action { font-weight: 650; }
.server-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; margin-top: 22px; }
.server-card { min-width: 0; position: relative; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 2px 7px var(--shadow); scroll-margin-top: 18px; }
.server-card:target, .server-card.selected-server { border-color: var(--selected); box-shadow: 0 0 0 1px var(--selected); }
h2 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 700; }
.server-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.server-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.server-status { display: inline-flex; align-items: center; gap: 5px; color: var(--online); white-space: nowrap; }
.server-status[data-status=offline] { color: var(--offline); }
.server-status[data-status=unknown] { color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.player-count { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-count .icon { width: 16px; height: 16px; color: var(--muted); }
.capacity { color: var(--muted); font-weight: 400; }
.address-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 40px; margin: 2px -6px 8px 0; }
.address { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions > .button { flex: 1 1 90px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border: 1px solid transparent; border-radius: 12px; text-align: center; text-decoration: none; font-size: 14px; font-weight: 650; line-height: 1.35; }
.app-icon { display: block; flex: none; object-fit: contain; }
.button .app-icon { width: 24px; height: 24px; }
.button[data-connect] { padding-top: 9px; padding-bottom: 9px; }
.primary { background: var(--accent); color: #fff; }
.secondary { background: var(--soft); border-color: var(--line); color: var(--accent-text); }
.connection-help-button { padding-top: 9px; padding-bottom: 9px; background: var(--help-soft); color: var(--help-ink); border-color: var(--help-line); }
.help-outside-picker { width: 100%; margin-top: 8px; }
.connect-picker { position: relative; }
.connect-picker[open] { z-index: 3; }
.connect-picker > summary { width: 100%; list-style: none; }
.connect-picker > summary::-webkit-details-marker { display: none; }
.connect-picker > summary::marker { content: ""; }
.connect-picker[open] > summary { border-color: var(--selected); }
.connect-picker .app-links { position: absolute; top: calc(100% + 6px); left: 0; right: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 8px 24px var(--shadow); }
.connect-picker .app-links > .button { justify-content: center; }
.connect-picker.opens-up .app-links { top: auto; bottom: calc(100% + 6px); }
.browser-action { width: 100%; }
.mobile-actions:not([hidden]) ~ .browser-action { margin-top: 8px; }
summary { padding: 16px 0; cursor: pointer; font-size: 14px; font-weight: 650; }
footer { margin-top: 22px; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; }
.download-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; }
.download-links a { display: inline-flex; align-items: center; min-height: 44px; }
.toast { position: fixed; z-index: 2; left: 50%; bottom: 20px; bottom: max(20px, env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px)); width: max-content; max-width: calc(100% - 32px); transform: translate(-50%, 8px); padding: 12px 16px; border: 1px solid var(--selected); border-radius: 14px; background: var(--panel); color: var(--ink); box-shadow: 0 5px 24px var(--shadow); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.copy-buffer { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; }
body.currency-welcome-open { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.currency-welcome-backdrop { position: fixed; inset: 0; z-index: 100; background: #08172f80; }
.connection-help-dialog { position: fixed; inset: 0; margin: auto; width: calc(100% - 32px); max-width: 520px; max-height: calc(100vh - 32px); max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px), var(--tg-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px))); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); box-shadow: 0 16px 48px #08172f33; overflow: auto; overscroll-behavior: contain; }
.connection-help-dialog:not([open]) { display: none; }
.connection-help-dialog::backdrop { background: #08172f80; }
.connection-help-dialog.currency-welcome-fallback { display: block; z-index: 101; top: 50%; bottom: auto; transform: translateY(-50%); }
.help-dialog-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.help-dialog-header > div { min-width: 0; }
.help-dialog-header h2 { font-size: 20px; }
.help-dialog-header p { margin: 5px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.help-dialog-body { padding: 16px 18px 18px; }
.help-dialog-body h3 { margin: 0 0 8px; font-size: 14px; }
.help-dialog-body p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.help-dialog-body kbd { padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; }
.manual-connect, .manual-alternative { margin-bottom: 16px; }
.command-box { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.command-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; -webkit-user-select: all; user-select: all; }
.command-box code:focus-visible { outline: 2px solid var(--selected); outline-offset: 3px; }
.help-dialog-body .command-status { min-height: 18px; margin: 4px 0 0; font-size: 12px; color: var(--accent-text); }
.manual-alternative code { color: var(--ink); overflow-wrap: anywhere; }
.connection-reasons details { border-top: 1px solid var(--line); }
.connection-reasons summary { padding: 12px 0; font-size: 13px; }
.connection-reasons details p { margin: 0 0 12px; }
@media (hover: hover) {
  .icon-button:hover { background: var(--soft); }
  .primary:hover { filter: brightness(1.08); }
  .secondary:hover { background: var(--hover); }
  .connection-help-button:hover { background: var(--help-hover); }
}
.button:active { transform: translateY(1px); }
@media (max-width: 680px) {
  .header-inner, main { padding-left: max(16px, env(safe-area-inset-left, 0px), var(--tg-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px), var(--tg-right, 0px)); }
  main { padding-top: 24px; }
  .server-list { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 18px; }
  .server-card { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .button:active { transform: none; }
}
