:root, html[data-theme="dark"] {
  --bg: #0f1113;
  --nav: #0b0d0f;
  --surface: #1a1d21;
  --surface-2: #23282f;
  --fg: #f1f3f5;
  --muted: #8b919a;
  --subtle: #6b717a;
  --border: #2c3138;
  --upvote: #ff5414;
  --downvote: #6a88f5;
  --shadow: 0 1px 0 rgba(255,255,255,.04);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #dae0e6;
  --nav: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f6;
  --fg: #121417;
  --muted: #5c6370;
  --subtle: #7a8190;
  --border: #d5dbe3;
  --upvote: #d63e0f;
  --downvote: #4f6fe0;
  --shadow: 0 1px 2px rgba(16,18,22,.08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%; height: 100%; width: 100%; max-width: 100%;
  background: var(--bg); color: var(--fg);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}
#app { min-height: 100%; }
body {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.ico { width: 22px; height: 22px; display: block; flex-shrink: 0; }
.mobile-only { display: none !important; }
.desktop-only { display: grid; }
button, [role="button"] { cursor: pointer; font: inherit; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: var(--fg); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
h1,h2,h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }
::selection { background: color-mix(in oklab, var(--upvote) 38%, transparent); }

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 10px;
  padding-top: env(safe-area-inset-top);
  min-height: calc(56px + env(safe-area-inset-top));
  background: var(--nav); border-bottom: 1px solid var(--border);
}
.tabbar { display: none; }
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font-weight: 700; letter-spacing: -.02em; }
.brand svg { display: block; }
.search {
  flex: 1; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 14px; height: 40px;
}
.search input {
  flex: 1; border: 0; background: transparent; outline: none; min-width: 0;
}
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: transparent; color: var(--fg);
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.rel { position: relative; }
.badge-dot {
  position: absolute; top: 7px; right: 7px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--upvote); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
.btn {
  border: 0; border-radius: 999px; height: 36px; padding: 0 14px;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--upvote); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-join { background: var(--fg); color: var(--bg); font-weight: 700; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: transparent;
  border-radius: 999px; height: 40px; padding: 0 10px 0 4px; color: var(--fg);
}
.avatar {
  width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.avatar.has-photo { background: var(--surface-2); overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.pfp-row { display: flex; gap: 12px; align-items: center; }
.btn-google {
  width: 100%; justify-content: center;
  background: #fff; color: #1b1b1b; border: 1px solid var(--border);
  height: 42px; margin-bottom: 8px;
}
html[data-theme="dark"] .btn-google { background: #f4f4f4; }
.or-split {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  margin: 14px 0;
}
.or-split::before, .or-split::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.auth-links {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 14px 0 0; font-size: 13px; color: var(--muted);
}
.auth-links a { color: var(--downvote); }

.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr) 312px; gap: 16px; width: 100%; max-width: 1280px; margin: 0 auto; padding: 16px 16px 48px; }
.nav, .rail { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 88px); overflow: auto; }
.nav a, .nav button.nav-link {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--fg); padding: 8px 10px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.nav a:hover, .nav button.nav-link:hover, .nav a.active { background: var(--surface); }
.nav .section { color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 16px 10px 6px; }
.nav-count {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--upvote); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}
.comm-dot { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; }

.feed { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.sortbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px;
}
.sortbar button {
  border: 0; background: transparent; color: var(--muted); border-radius: 999px;
  padding: 6px 12px; font-weight: 600; font-size: 13px;
}
.sortbar button.on, .sortbar button:hover { background: var(--surface-2); color: var(--fg); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.post { display: grid; grid-template-columns: 40px minmax(0,1fr); }
.post:hover { border-color: color-mix(in oklab, var(--fg) 22%, var(--border)); }
.votes {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; background: color-mix(in oklab, var(--surface-2) 55%, transparent);
}
.votes button {
  border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 6px;
}
.votes button:hover { background: var(--surface-2); }
.votes button.up.on, .votes .score.up { color: var(--upvote); }
.votes button.down.on, .votes .score.down { color: var(--downvote); }
.score { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px; color: var(--fg); }
.post-body { padding: 10px 14px 12px; min-width: 0; }
.meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.meta a:hover { text-decoration: underline; }
.title { margin: 6px 0 8px; font-size: 18px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.title a:hover { text-decoration: underline; }
.flair {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); margin-right: 6px;
}
.preview { color: var(--muted); font-size: 14px; max-height: 72px; overflow: hidden; }
.post-image { margin: 8px 0; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.post-image img { width: 100%; max-height: 420px; object-fit: cover; display: block; }
.link-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--downvote); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.actions button, .actions a.act {
  border: 0; background: transparent; color: var(--muted);
  height: 32px; padding: 0 8px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
}
.actions button:hover, .actions a.act:hover { background: var(--surface-2); color: var(--fg); }
.awards { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.award {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: 2px 8px;
}

.rail .card { padding: 14px; margin-bottom: 12px; }
.rail h3 { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--subtle); margin-bottom: 10px; }
.banner {
  height: 72px; border-radius: 8px; margin: -14px -14px 12px;
  background: linear-gradient(135deg, hsl(var(--h, 210) 40% 28%), hsl(calc(var(--h, 210) + 24) 50% 18%));
}
.community-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.community-row .grow { flex: 1; min-width: 0; }
.community-row .sub { color: var(--muted); font-size: 12px; }

.thread { padding: 0; }
.thread-post { padding: 8px 16px 16px; }
.composer textarea, .form textarea, .form input, .form select {
  width: 100%; padding: 10px 12px; outline: none;
}
.composer textarea:focus, .form input:focus, .form textarea:focus { border-color: var(--upvote); }
.composer { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.comments { padding: 0 16px 24px; }
.comment { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 8px; margin-top: 12px; }
.comment .thread-line { width: 2px; background: var(--border); margin: 0 auto; border-radius: 2px; min-height: 100%; }
.comment .c-body { min-width: 0; }
.comment .c-text { font-size: 14px; margin: 4px 0; }
.replies { margin-left: 8px; padding-left: 8px; border-left: 2px solid var(--border); }

.page-head { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.page-banner { height: 96px; }
.page-head .inner { padding: 12px 16px 16px; display: flex; gap: 12px; align-items: flex-end; margin-top: -28px; }
.page-head h1 { font-size: 22px; }
.tabs { display: flex; gap: 4px; padding: 0 8px 8px; border-top: 1px solid var(--border); }
.tabs a, .tabs button {
  border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  padding: 10px 12px; border-bottom: 2px solid transparent;
}
.tabs a.on, .tabs button.on { color: var(--fg); border-bottom-color: var(--upvote); }

.form { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.form label { font-size: 12px; font-weight: 600; color: var(--muted); }
.type-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.type-tabs button {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 10px 14px; font-weight: 600; min-height: 44px;
}
.type-tabs button.on { background: var(--surface-2); color: var(--fg); border-color: var(--fg); }
.file-pick { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.file-pick-title { font-size: 13px; font-weight: 600; color: var(--fg); }
.file-input-vis {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 16px;
}
.file-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.file-preview img, .file-preview video {
  max-width: 160px;
  max-height: 160px;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
}
.file-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.login-wrap { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 28px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card p.lead { color: var(--muted); margin: 0 0 18px; }
.menu {
  position: absolute; right: 12px; top: 52px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  min-width: 220px; padding: 6px; box-shadow: var(--shadow);
}
.menu a, .menu button {
  display: flex; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--fg); padding: 8px 10px; border-radius: 8px; font-size: 14px; gap: 8px; align-items: center;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 80;
}
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.md strong { font-weight: 650; }
.md em { font-style: italic; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.md a { color: var(--downvote); text-decoration: underline; }
.compact .post { grid-template-columns: 52px minmax(0,1fr); }
.compact .title { font-size: 15px; margin: 2px 0 4px; }
.compact .preview, .compact .post-image { display: none; }
.msg-list { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.bubble.mine { align-self: flex-end; background: color-mix(in oklab, var(--upvote) 25%, var(--surface-2)); }
.hamburger { display: none; }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.gallery img { width: 100%; height: 180px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.post-video { width: 100%; max-height: 420px; margin: 8px 0; border-radius: 8px; background: #000; }
.empty-hero { padding: 36px 20px; text-align: center; }
.empty-hero h1 { font-size: 22px; margin-bottom: 8px; }
.empty-hero p { color: var(--muted); max-width: 460px; margin: 0 auto 16px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mod-row { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.mod-row:last-child { border-bottom: 0; }
.chip { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 13px; }
.chip.on, .chip:hover { background: var(--surface-2); color: var(--fg); }
.rules-list { color: var(--fg); padding-left: 20px; }
.rules-list li { margin: 8px 0; }
.grow { flex: 1; min-width: 0; }
.web-promo {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.guest-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.menu-guest { padding: 8px 10px; color: var(--muted); font-size: 12px; }

html.app-compact .shell { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 96px; }
html.app-compact .nav, html.app-compact .rail { display: none; }
html.app-compact .nav.open {
  display: block; position: fixed; inset: 56px auto 0 0; width: min(84vw, 300px);
  background: var(--nav); border-right: 1px solid var(--border); z-index: 30; padding: 12px;
  max-height: calc(100vh - 56px); overflow: auto;
}
html.app-compact .nav a { min-height: 44px; font-size: 15px; }
html.app-compact .hamburger { display: grid; }
html.app-compact .desktop-search { display: none !important; }
html.app-compact .desktop-only { display: none !important; }
html.app-compact .mobile-only { display: grid !important; }
html.app-compact .nav-scrim {
  display: block; position: fixed; inset: 56px 0 0 0;
  background: rgba(0,0,0,.45); z-index: 29;
}
html.app-compact .icon-btn { width: 44px; height: 44px; }
html.app-compact .header-actions { gap: 2px; }
html.app-compact .tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--nav);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
html.app-compact .tabbar .tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 52px; color: var(--muted);
  font-size: 11px; font-weight: 600; border-radius: 10px;
}
html.app-compact .tabbar .tab.on { color: var(--fg); }
html.app-compact .tabbar .tab .ico { width: 24px; height: 24px; }
html.app-compact .toast { bottom: 84px; }
html.app-compact .login-wrap { padding: 16px 16px 96px; }
html.app-compact .user-chip { padding: 0; width: 44px; height: 44px; justify-content: center; border: 0; }
html.app-compact .user-chip span.name { display: none; }
html.app-compact .brand span.word { display: none; }
html.app-compact .post { grid-template-columns: 1fr; }
html.app-compact .votes { flex-direction: row; justify-content: flex-start; padding: 0 12px 8px; }

/* Itch.io Run game is often a wide landscape iframe. Keep a portrait phone column. */
html.phone-shell,
html.phone-shell body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}
html.phone-shell body {
  display: grid;
  place-items: center;
  background: #07080a;
}
html.phone-shell #app {
  position: relative;
  width: min(430px, 100vw);
  height: 100%;
  max-height: 100%;
  overflow: auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px #1c2026;
}
html.phone-shell .header { position: sticky; top: 0; }
html.phone-shell .tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: sticky;
  left: auto;
  right: auto;
  bottom: 0;
  width: 100%;
  z-index: 45;
  background: var(--nav);
  border-top: 1px solid var(--border);
  padding: 6px 4px 8px;
}
html.phone-shell .tabbar .tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
html.phone-shell .tabbar .tab.on { color: var(--fg); }
html.phone-shell .shell { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 16px; }
html.phone-shell .nav, html.phone-shell .rail { display: none; }
html.phone-shell .nav.open {
  display: block;
  position: absolute;
  inset: 56px auto 0 0;
  width: min(84%, 300px);
  background: var(--nav);
  border-right: 1px solid var(--border);
  z-index: 30;
  padding: 12px;
}
html.phone-shell .nav-scrim {
  display: block;
  position: absolute;
  inset: 56px 0 0 0;
  background: rgba(0,0,0,.45);
  z-index: 29;
}
html.phone-shell .hamburger { display: grid; }
html.phone-shell .desktop-search { display: none !important; }
html.phone-shell .desktop-only { display: none !important; }
html.phone-shell .mobile-only { display: grid !important; }
html.phone-shell .user-chip { padding: 0; width: 44px; height: 44px; justify-content: center; border: 0; }
html.phone-shell .user-chip span.name { display: none; }
html.phone-shell .brand span.word { display: none; }
html.phone-shell .post { grid-template-columns: 1fr; }
html.phone-shell .votes { flex-direction: row; justify-content: flex-start; padding: 0 12px 8px; }

@media (max-width: 1020px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 96px; }
  .nav, .rail { display: none; }
  .nav.open {
    display: block; position: fixed; inset: 56px auto 0 0; width: min(84vw, 300px);
    background: var(--nav); border-right: 1px solid var(--border); z-index: 30; padding: 12px;
    max-height: calc(100vh - 56px);
  }
  .nav a { min-height: 44px; font-size: 15px; }
  .hamburger { display: grid; }
  .desktop-search { display: none !important; }
  .desktop-only { display: none !important; }
  .mobile-only { display: grid !important; }
  .nav-scrim {
    display: block; position: fixed; inset: 56px 0 0 0;
    background: rgba(0,0,0,.45); z-index: 29;
  }
  .icon-btn { width: 44px; height: 44px; }
  .header-actions { gap: 2px; }
  .hdr-login { height: 36px; padding: 0 12px; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--nav);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .tabbar .tab {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 52px; color: var(--muted);
    font-size: 11px; font-weight: 600; border-radius: 10px;
  }
  .tabbar .tab.on { color: var(--fg); }
  .tabbar .tab .ico { width: 24px; height: 24px; }
  .tabbar .tab .avatar { width: 24px; height: 24px; font-size: 11px; }
  .tabbar .tab .badge-dot { top: 4px; right: 18%; }
  .toast { bottom: 84px; }
  .login-wrap { padding: 16px 16px 96px; }
}
@media (max-width: 640px) {
  .user-chip { padding: 0; width: 44px; height: 44px; justify-content: center; border: 0; }
  .user-chip span.name { display: none; }
  .brand span.word { display: none; }
  .post { grid-template-columns: 1fr; }
  .votes { flex-direction: row; justify-content: flex-start; padding: 0 12px 8px; }
  .votes button { width: 44px; height: 44px; }
  .title { font-size: 17px; }
  .page-head .inner { flex-wrap: wrap; align-items: center; }
}
