/* PortForge: sticky header with nav and member menu; ports page has a category rail and weapon grid. */
:root {
  --bg: #12161b;
  --panel: #1a2027;
  --panel-2: #212932;
  --line: #2c3540;
  --line-hi: #3d4957;
  --fg: #e6eaee;
  --muted: #8d99a6;
  --accent: #f0a63a;
  --accent-fg: #1a1206;
  --danger: #f07a6a;
  --font-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.wrap { max-width: 1240px; margin: 0 auto; width: 100%; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
header.site { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 20px; padding-block: 10px; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark { width: 28px; height: 28px; border: 2px solid var(--accent); border-radius: 4px; display: grid; place-items: center; font-size: 13px; color: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: .04em; color: var(--muted); text-decoration: none; padding: 8px 14px; border-radius: 4px; }
.nav a:hover { color: var(--fg); background: var(--panel-2); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--panel-2); }
.session { margin-left: auto; display: flex; align-items: center; gap: 8px; min-height: 38px; }
.session-ph { display: block; width: 120px; height: 36px; border-radius: 999px; background: var(--panel-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 4px; font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: .05em; text-transform: uppercase; padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn svg { width: 14px; height: 14px; }
.btn[disabled], .btn.off { background: var(--panel-2); color: var(--muted); cursor: default; filter: none; }
.btn-ghost { background: none; color: var(--fg); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--line-hi); filter: none; }

/* Member menu */
.menu { position: relative; }
.menu-btn { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); font: inherit; font-size: 14px; padding: 3px 12px 3px 3px; border-radius: 999px; cursor: pointer; }
.menu-btn:hover { border-color: var(--line-hi); }
.menu-btn svg { width: 12px; height: 12px; color: var(--muted); }
.menu-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--bg); color: var(--accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 48px; height: 48px; font-size: 20px; }
.avatar.xl { width: 88px; height: 88px; font-size: 36px; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.45); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.menu-head { display: flex; gap: 12px; align-items: center; padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; min-width: 0; }
.menu-head div { min-width: 0; display: flex; flex-direction: column; }
.menu-head b { font-family: var(--font-display); font-size: 16px; overflow-wrap: anywhere; }
.menu-head span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.menu-pop a, .menu-pop button.item { display: block; text-align: left; background: none; border: 0; color: var(--fg); font: inherit; font-size: 14px; padding: 9px 10px; border-radius: 4px; text-decoration: none; cursor: pointer; width: 100%; }
.menu-pop a:hover, .menu-pop button.item:hover { background: var(--panel-2); }
.menu-pop a.primary { color: var(--accent); font-weight: 600; }

/* Page intro */
.intro { padding-block: 32px 20px; display: flex; gap: 24px; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.intro h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; margin: 0 0 6px; text-wrap: balance; }
.intro p { margin: 0; color: var(--muted); max-width: 60ch; }
.stats { display: flex; gap: 20px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.stats b { display: block; font-size: 20px; color: var(--fg); font-weight: 500; }

/* Game tabs */
.games { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 24px; }
.games a { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: .04em; color: var(--muted); text-decoration: none; padding: 10px 18px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.games a:hover { color: var(--fg); }
.games a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.games .tag { font-family: var(--font-body); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-left: 6px; }

/* Common files */
.common { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; padding: 16px 18px; margin-bottom: 24px; }
.common-text { flex: 1 1 280px; min-width: 0; }
.common h2 { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 0 0 2px; }
.common p { margin: 0; color: var(--muted); font-size: 14px; }
.file { font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

.soon { text-align: center; border: 1px dashed var(--line); border-radius: 6px; padding: 56px 16px; margin-bottom: 48px; }
.soon-tag { display: inline-block; font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-fg); background: var(--accent); padding: 4px 12px; border-radius: 3px; }
.soon h2 { font-family: var(--font-display); font-size: 26px; margin: 14px 0 6px; text-wrap: balance; }
.soon p { margin: 0 auto; color: var(--muted); max-width: 50ch; }

/* Ports layout */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding-block: 8px 48px; }
.rail { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.rail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 0 12px 8px; }
.cat { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; background: none; border: 0; border-left: 2px solid transparent; color: var(--muted); font: inherit; font-size: 14px; text-align: left; padding: 8px 12px; cursor: pointer; }
.cat:hover { color: var(--fg); background: var(--panel); }
.cat[aria-pressed="true"] { color: var(--fg); border-left-color: var(--accent); background: var(--panel); }
.cat .n { font-family: var(--font-mono); font-size: 12px; }
.tools { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.search { flex: 1 1 260px; min-width: 0; background: var(--panel); border: 1px solid var(--line); color: var(--fg); font: inherit; padding: 10px 14px; border-radius: 4px; }
.search::placeholder { color: var(--muted); }
.count { font-size: 13px; color: var(--muted); }
.group { margin-bottom: 32px; }
.group h2 { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; }
.group h2 span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card:hover { border-color: var(--line-hi); }
.card h3 { font-family: var(--font-display); font-weight: 600; font-size: 19px; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.empty, .loading { color: var(--muted); padding: 40px 0; text-align: center; }
.error { color: var(--danger); font-size: 14px; }

/* Community */
.cm { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 28px; align-items: start; padding-block: 8px 48px; }
.side { position: sticky; top: 76px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.panel h2 { font-family: var(--font-display); font-size: 18px; margin: 0 0 4px; }
.panel p { margin: 0; color: var(--muted); font-size: 14px; }
.panel .row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
form label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 8px; }
form input, form select, form textarea { background: var(--bg); border: 1px solid var(--line); color: var(--fg); font: inherit; padding: 9px 12px; border-radius: 4px; width: 100%; resize: vertical; }
form .btn { margin-top: 12px; }
.note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: none; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { color: var(--fg); border-color: var(--accent); }
.feed { display: flex; flex-direction: column; gap: 12px; }
.post { flex-direction: row; gap: 14px; }
.post .avatar { width: 40px; height: 40px; }
.post-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.post-meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.post-meta b { color: var(--fg); font-weight: 600; }
.pill { font-family: var(--font-mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; }
.post h3 { font-size: 18px; }
.post p { margin: 0; opacity: .88; overflow-wrap: anywhere; white-space: pre-line; }
.post .btn { align-self: flex-start; font-size: 12px; padding: 6px 12px; }

/* Login + account */
.narrow { max-width: 440px; margin: 0 auto; padding-block: 48px; }
.narrow h1 { font-family: var(--font-display); font-size: 30px; margin: 0 0 4px; }
.narrow .sub { color: var(--muted); margin: 0 0 20px; }
.switch { font-size: 14px; color: var(--muted); margin-top: 14px; }
.switch button { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.profile { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding-block: 36px 24px; }
.profile h1 { font-family: var(--font-display); font-size: 32px; margin: 0; overflow-wrap: anywhere; }
.profile p { margin: 2px 0 0; color: var(--muted); }
.section-h { font-family: var(--font-display); font-size: 20px; margin: 8px 0 12px; }

footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
footer.site .wrap { padding-block: 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .bar { gap: 10px; }
  .session { margin-left: auto; }
  .nav { order: 3; width: 100%; }
  .nav a { flex: 1; text-align: center; }
  .layout, .cm { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .rail, .side { position: static; }
  .rail { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .rail-label { display: none; }
  .cat { width: auto; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
  .cat[aria-pressed="true"] { border-color: var(--accent); }
  .games a { flex: 1; text-align: center; padding: 10px 6px; }
  .menu-name { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
