/* Fitz & Pop brand: cream #F4DAB5, logo blue #5B85D8 */
:root[data-theme="dark"] {
  --bg: #0e0e12; --panel: #1a1a22; --panel-2: #23232f; --line: #2c2c3a;
  --text: #f4f4f8; --muted: #a6a6b8; --title: #7aa0e6; --accent: #5b85d8;
  --accent-contrast: #ffffff; --gold: #e8c15a; --logo-pad: #f4dab5;
  --tile-bg: #0d0d14;
}
:root[data-theme="light"] {
  --bg: #f4dab5; --panel: #ffffff; --panel-2: #fbf3e6; --line: #e4c99b;
  --text: #1a1a1a; --muted: #7a6f57; --title: #4d78cf; --accent: #5b85d8;
  --accent-contrast: #ffffff; --gold: #b78a1f; --logo-pad: #f4dab5;
  --tile-bg: #efe3cc;
}
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); transition: background .2s, color .2s; }
a { color: inherit; }

/* header */
.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.4rem; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); z-index: 10; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; text-decoration: none;
  font-size: 1.15rem; color: var(--title); }
.brand img { height: 30px; width: auto; display: block; border-radius: 6px; }
.nav { display: flex; align-items: center; gap: 1.1rem; }
.nav a { text-decoration: none; color: var(--muted); font-size: .92rem; }
.nav a.active, .nav a:hover { color: var(--text); }
.nav .me { display: flex; align-items: center; gap: .5rem; }
.nav .me img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.btn { background: var(--accent); color: var(--accent-contrast); border: 0; padding: .55rem 1rem;
  border-radius: 8px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.btn.ghost:hover { color: var(--text); }
.theme-toggle { font-size: 1rem; line-height: 1; padding: .5rem .6rem; }

main { max-width: 960px; margin: 0 auto; padding: 2rem 1.4rem 3rem; }
h1 { font-size: 1.5rem; margin: 0 0 1.4rem; color: var(--title); }
h2 { font-size: 1.15rem; margin: 2rem 0 1rem; color: var(--title); }
.muted { color: var(--muted); }

/* game grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: transform .12s, border-color .12s; }
.tile:hover { transform: translateY(-4px); border-color: var(--accent); }
.tile .art { aspect-ratio: 16/10; width: 100%; object-fit: cover; display: block; background: var(--tile-bg); }
.tile .body { padding: 1rem 1.1rem 1.2rem; }
.tile .body h3 { margin: 0 0 .3rem; font-size: 1.1rem; }
.tile .body p { margin: 0; color: var(--muted); font-size: .88rem; }

/* forms / panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 .4rem; }
input[type=text], input[type=file] { width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: .7rem .8rem; font-size: .95rem; }
.field { margin-bottom: 1.2rem; }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.notice { background: color-mix(in srgb, #2f9e5f 22%, var(--panel)); border: 1px solid #2f9e5f; color: var(--text); padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.err { background: color-mix(in srgb, #d64545 22%, var(--panel)); border: 1px solid #d64545; color: var(--text); padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.warn { background: color-mix(in srgb, #e0a020 24%, var(--panel)); border: 1px solid #e0a020; color: var(--text); padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }

/* connected accounts (profile) */
.linkrow { display: flex; align-items: center; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.linkrow:first-of-type { border-top: 0; }
.linkrow .prov { display: flex; align-items: center; gap: .7rem; flex: 1; }
.linkrow .prov-name { font-size: .98rem; color: var(--text); font-weight: 500; }
.prov-glyph { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 50%; font-weight: 800; font-size: 1rem; color: #fff; flex: 0 0 30px; }
.prov-glyph.g { background: #4285f4; font-family: Georgia, "Times New Roman", serif; }
.prov-glyph.f { background: #1877f2; }
.prov-status.ok { color: #2f9e5f; font-weight: 600; font-size: .92rem; }
.linked-note { margin: 1rem 0 0; padding-top: .9rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .88rem; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 500; }
.rank { color: var(--gold); font-weight: 700; width: 2.5rem; }
.pname { display: flex; align-items: center; gap: .6rem; }
.pname img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.empty { color: var(--muted); padding: 1rem 0; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1.5rem; }
.login-card { max-width: 420px; }
.login-logo { width: 260px; max-width: 80%; height: auto; border-radius: 12px; margin: 0 auto 1.4rem; display: block; }
:root[data-theme="dark"] .login-logo { box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.login-card h1 { font-size: 1.5rem; margin: 0 0 .4rem; }
.g-btn { display: inline-flex; align-items: center; gap: .6rem; background: #fff; color: #1f1f1f;
  text-decoration: none; padding: .8rem 1.4rem; border-radius: 8px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.corner-toggle { position: fixed; top: 1rem; right: 1rem; }

/* consent checkboxes */
.consent { text-align: left; margin: 0 0 1.4rem; display: flex; flex-direction: column; gap: .7rem; }
.consent .check { display: flex; align-items: flex-start; gap: .55rem; font-size: .88rem; color: var(--text);
  margin: 0; cursor: pointer; line-height: 1.45; }
.consent .check input { margin: .15rem 0 0; width: 16px; height: 16px; flex: 0 0 16px; accent-color: var(--accent); cursor: pointer; }
.consent .check a { color: var(--accent); text-decoration: underline; }
.consent .check em { font-style: normal; }

/* provider buttons: full-width stack; disabled until T&C accepted */
.providers { display: flex; flex-direction: column; gap: .7rem; }
.providers .provider { width: 100%; justify-content: center; border: 0; cursor: pointer; font-size: .95rem; }
.fb-btn { display: inline-flex; align-items: center; gap: .6rem; background: #1877f2; color: #fff;
  padding: .8rem 1.4rem; border-radius: 8px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.discord-btn { display: inline-flex; align-items: center; gap: .6rem; background: #5865f2; color: #fff;
  padding: .8rem 1.4rem; border-radius: 8px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.fb-btn:hover:not(:disabled) { filter: brightness(1.06); }
.discord-btn:hover:not(:disabled) { filter: brightness(1.06); }
.g-btn:hover:not(:disabled) { filter: brightness(.97); }
.providers .provider:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; filter: grayscale(.4); }

/* game shell: slim arcade bar + the game in a frame beneath it */
.shell { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
.game-bar { flex: 0 0 42px; display: flex; align-items: center; gap: .9rem; padding: 0 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.game-bar .home { display: inline-flex; align-items: center; gap: .4rem; color: var(--title);
  text-decoration: none; font-weight: 700; font-size: .95rem; }
.game-bar .home:hover { filter: brightness(1.15); }
.game-bar .game-name { margin-left: auto; color: var(--muted); font-size: .88rem; }
.game-frame { flex: 1 1 auto; width: 100%; border: 0; display: block; background: #000; }

/* mobile header: wrap the nav to its own row so nothing gets clipped */
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: .5rem .7rem; padding: .6rem 1rem; }
  .brand { font-size: 1.05rem; }
  .brand img { height: 26px; }
  .nav { width: 100%; justify-content: space-between; gap: .5rem; font-size: .85rem; }
  .nav .me .uname { display: none; } /* keep the avatar, drop the name to save room */
  main { padding: 1.4rem 1rem 2.5rem; }
}

/* legal pages (Terms, Privacy) — readable prose column */
main.legal { max-width: 760px; }
.legal-doc { font-size: .95rem; line-height: 1.65; color: var(--text); }
.legal-doc h1 { font-size: 1.6rem; margin: 0 0 1rem; }
.legal-doc h2 { font-size: 1.2rem; margin: 2.2rem 0 .8rem; }
.legal-doc h3 { font-size: 1rem; margin: 1.4rem 0 .6rem; color: var(--title); }
.legal-doc p, .legal-doc li { color: var(--text); }
.legal-doc a { color: var(--accent); text-decoration: underline; }
.legal-doc a:hover { filter: brightness(1.15); }
.legal-doc ul { padding-left: 1.3rem; }
.legal-doc hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.legal-doc strong { color: var(--text); }
.legal-doc table { width: 100%; border-collapse: collapse; margin: 1rem 0; display: block; overflow-x: auto; }
.legal-doc th, .legal-doc td { text-align: left; padding: .6rem .7rem; border: 1px solid var(--line); font-size: .9rem; vertical-align: top; }
.legal-doc th { color: var(--muted); font-weight: 600; background: var(--panel-2); }

/* ===== Storefront (arcade page) ========================================== */
main.store { max-width: 1180px; }
[hidden] { display: none !important; }

.store-search { margin: 0 0 1.2rem; }
.store-search input { width: 100%; max-width: 560px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: .7rem .95rem; font-size: .98rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.1rem; margin: 0 0 1.6rem; }
.toolbar .lab { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.sbtn { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 8px;
  padding: .4rem .7rem; font-size: .82rem; cursor: pointer; }
.sbtn:hover { color: var(--text); }
.sbtn.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 22%, var(--panel)); }
.chip { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 999px;
  padding: .34rem .8rem; font-size: .8rem; cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.on { border-color: var(--gold); color: var(--accent-contrast); background: var(--gold); font-weight: 600; }

.pubhead { display: flex; align-items: center; gap: .8rem; margin: 2rem 0 1rem; }
.pubhead.future { margin-top: 2.6rem; }
.pubhead .plogo { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: .82rem; background: linear-gradient(135deg, var(--accent), var(--title)); }
.pubhead .plogo.alt { background: linear-gradient(135deg, #3a3a48, #55556a); font-size: 1.2rem; }
.pubhead h2 { margin: 0; font-size: 1.2rem; color: var(--text); }
.pubhead .count { color: var(--muted); font-size: .82rem; }

.store-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { display: flex; flex-direction: column; text-decoration: none; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card.locked { cursor: pointer; }
.card .cap { position: relative; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center;
  background: var(--tile-bg); overflow: hidden; }
.card .cap img { max-width: 82%; max-height: 82%; width: auto; height: auto; object-fit: contain; display: block; }
.card .cap .emoji { font-size: 2.7rem; letter-spacing: .2rem; }
.card .cap .lock { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; line-height: 1; padding: 4px 7px; border-radius: 8px; background: rgba(0,0,0,.62); opacity: 1; }
.card .cbody { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.card .cbody h3 { margin: 0; font-size: 1.06rem; }
.card .tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.card .tag { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: .1rem .45rem; font-size: .72rem; }
.card .stats { display: flex; flex-wrap: wrap; gap: .3rem .9rem; color: var(--muted); font-size: .78rem;
  margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--line); }
.card .stats b { color: var(--text); }
.card .stats .fin b { color: #3ecf8e; }
.card .stats .win b { color: var(--gold); }
.card .stats .new { color: var(--title); }

.none { color: var(--muted); padding: .8rem 0 1.4rem; }
.empty-pub { border: 1px dashed var(--line); border-radius: 14px; padding: 2rem; text-align: center; color: var(--muted); }

/* beta unlock / info modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; padding: 1.5rem; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem; max-width: 380px; width: 100%; }
.modal h3 { margin: 0 0 .6rem; font-size: 1.2rem; color: var(--title); }
.modal p { margin: 0 0 1rem; font-size: .9rem; }
.modal input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: .7rem .8rem; font-size: .95rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }

@media (max-width: 600px) {
  .store-grid { grid-template-columns: 1fr; }
}

/* --- Gamification: level, XP, streak, badges (Phase 1) ------------------- */
.progress-panel { border-top: 3px solid var(--gold); }
.prog-top { display: flex; align-items: center; gap: 1.2rem; }
.lvl-badge {
  flex: 0 0 auto; width: 76px; height: 76px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--gold) 85%, #fff) 0%, var(--gold) 70%);
  color: #3a2c00; box-shadow: 0 4px 14px color-mix(in srgb, var(--gold) 40%, transparent);
  border: 2px solid color-mix(in srgb, var(--gold) 60%, #fff);
}
.lvl-badge .lvl-num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.lvl-badge .lvl-cap { font-size: .52rem; font-weight: 700; letter-spacing: .12em; margin-top: 2px; }
.prog-main { flex: 1 1 auto; min-width: 0; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; margin-bottom: .45rem; flex-wrap: wrap; }
.prog-head strong { font-size: 1.05rem; }
.prog-head .muted { font-size: .82rem; }
.xp-bar { height: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.xp-bar > span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .4s ease;
}
.prog-stats { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin-top: .7rem; font-size: .86rem; }
.prog-stats strong { color: var(--text); }
.badges-title { margin: 1.5rem 0 .8rem; font-size: 1rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.badge {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: .3rem; padding: .9rem .6rem; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.badge.earned { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 25%, transparent); }
.badge.locked { opacity: .45; filter: grayscale(1); }
.badge-ico { font-size: 1.7rem; line-height: 1; }
.badge-name { font-weight: 700; font-size: .82rem; }
.badge-desc { font-size: .7rem; line-height: 1.25; }
@media (max-width: 600px) {
  .prog-stats { gap: .35rem .8rem; }
  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .badge-desc { display: none; }
}

/* Leaderboard: level chip + earned-badge emojis next to each player */
.pname-txt { font-weight: 600; }
.lvl-chip {
  display: inline-block; margin-left: .5rem; padding: .05rem .45rem; border-radius: 99px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em; vertical-align: middle;
  white-space: nowrap;   /* never break "Lv 3" into a two-line stack in a tight cell */
  color: #3a2c00; background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 88%, #fff), var(--gold));
  border: 1px solid color-mix(in srgb, var(--gold) 55%, #fff);
}
.lb-badges { display: inline-flex; flex-wrap: wrap; gap: .1rem; margin-top: .25rem; font-size: .95rem; line-height: 1; }
.lb-badge { cursor: default; }
.lb-more { font-size: .72rem; align-self: center; margin-left: .15rem; }

/* Per-game leaderboard tables: wrap long headers, per-row "i" details on mobile */
.beta-tag {
  display: inline-block; margin-left: .55rem; padding: .1rem .5rem; border-radius: 99px;
  font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-contrast); background: var(--accent); vertical-align: middle;
}
/* Leaderboard section header: title left, "Discover the game" link right. */
h2.lb-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2.lb-head .lb-title { margin-right: auto; display: flex; align-items: center; gap: .2rem; }
.discover-btn {
  font-size: .8rem; font-weight: 600; padding: .4rem .8rem; border-radius: 9px;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  text-decoration: none; white-space: nowrap; transition: .15s;
}
.discover-btn:hover { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); }
.discover-btn .ar { opacity: .7; font-size: .9em; }

.lb { width: 100%; border-collapse: collapse; table-layout: auto; }
.lb th, .lb td { white-space: normal; overflow-wrap: anywhere; vertical-align: middle; padding: .5rem .6rem; }
.lb thead th { font-size: .8rem; line-height: 1.25; color: var(--muted); text-align: left; }
.lb .rank { width: 2rem; text-align: center; color: var(--muted); }
.lb .col-i { display: none; width: 2.2rem; }
.i-btn {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); font: italic 700 .9rem/1 serif; cursor: pointer;
  align-items: center; justify-content: center;
}
.i-btn.open { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.row-detail .detail-cell { background: var(--panel-2); padding: .6rem .8rem; border-radius: 0 0 8px 8px; }
.d-item { display: inline-flex; gap: .35rem; margin: .2rem 1rem .2rem 0; font-size: .86rem; }
.d-lbl { color: var(--muted); }
@media (max-width: 760px) {
  .lb .col-extra { display: none; }
  .lb .col-i { display: table-cell; }
  .i-btn { display: inline-flex; }
  .lb th, .lb td { padding: .5rem .4rem; }
  .lb-badges { font-size: .85rem; }
}

/* Leaderboard mode tabs (Presina): one board per game mode inside the panel. */
.lb-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem;
  border-bottom: 1px solid var(--line); padding-bottom: .8rem; }
.lb-tab { font-size: .82rem; font-weight: 600; padding: .38rem .8rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: .15s; }
.lb-tab:hover { color: var(--text); border-color: var(--gold); }
.lb-tab.active { color: #3a2c00; background: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 60%, #fff); }
.lb-tabpanel.hidden { display: none; }

/* Admin panel */
.admin-tiles { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: 1.4rem; }
.atile { flex: 1 1 120px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; }
.atile .anum { display: block; font-size: 1.9rem; font-weight: 800; color: var(--title); line-height: 1; }
.atile .albl { display: block; margin-top: .3rem; font-size: .8rem; color: var(--muted); }
.admin-table td, .admin-table th { font-size: .84rem; }
.admin-table a { color: var(--title); text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }

/* Clickable leaderboard names → public profile */
.pname-link { color: var(--text); text-decoration: none; }
.pname-link:hover { color: var(--title); text-decoration: underline; }

/* Profile form selects — match the text inputs */
.field select {
  width: 100%; padding: .55rem .6rem; font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.field select:focus { outline: none; border-color: var(--accent); }

/* Public profile page */
.pub-head { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.pub-id h1 { margin: 0; }
.pub-flag { font-size: 1.4rem; vertical-align: middle; }
.pub-bio { margin: .5rem 0 0; font-size: .95rem; }
.pub-meta { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; margin-top: .6rem; font-size: .86rem; }
.pub-meta strong { color: var(--text); }
.prof-private { display: flex; align-items: center; gap: 1.1rem; }

/* --- theme-aware cutout logo (topbar, rail, footer) --- */
/* attribute selectors outrank .brand img, so the swap holds in both themes */
:root[data-theme="dark"]  .logo-light { display: none; }
:root[data-theme="dark"]  .logo-dark  { display: block; }
:root[data-theme="light"] .logo-light { display: block; }
:root[data-theme="light"] .logo-dark  { display: none; }
.brand .logo-dark, .brand .logo-light { height: 26px; width: auto; border-radius: 0; }
.brand .brand-sub { color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase;
  letter-spacing: 1.5px; padding-left: .55rem; border-left: 1px solid var(--line); }

/* --- arcade home: 3-column layout (brand rail · games · community rail) --- */
.arcade-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr) 268px;
  gap: 1.9rem; max-width: 1520px; margin: 0 auto; padding: 2rem 1.6rem 1rem; align-items: start; }
.arcade-layout main.store { max-width: none; margin: 0; padding: 0; }

.rail { position: sticky; top: 84px; }
.rail-left .rail-brand { display: block; }
.rail-left .rail-brand img { width: 168px; height: auto; }
.rail-left .rail-tag { margin: .5rem 0 0; color: var(--gold); font-weight: 700; font-size: .74rem;
  text-transform: uppercase; letter-spacing: 2px; }
.rail-left .rail-blurb { margin: .9rem 0 1.3rem; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.rail-links { display: flex; flex-direction: column; gap: .2rem; }
.rail-links a { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: 9px;
  color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 500; transition: background .15s; }
.rail-links a:hover { background: var(--panel-2); }
.rail-links .ri { font-size: 1rem; }

/* right rail — community / Discord funnel */
.community { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem 1.3rem 1.4rem; }
.community .c-eyebrow { margin: 0 0 .35rem; color: var(--gold); font-weight: 700; font-size: .72rem;
  text-transform: uppercase; letter-spacing: 1.5px; }
.community h3 { margin: 0 0 .5rem; font-size: 1.1rem; color: var(--title); line-height: 1.25; }
.community .c-sub { margin: 0 0 1.1rem; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.discord-cta { display: flex; align-items: center; justify-content: center; gap: .5rem; width: 100%;
  background: #5865F2; color: #fff; font-weight: 700; border: 0; padding: .7rem 1rem; border-radius: 10px;
  text-decoration: none; font-size: .95rem; transition: filter .15s, transform .15s; }
.discord-cta:hover { filter: brightness(1.08); transform: translateY(-1px); }
.discord-cta svg { width: 20px; height: 20px; fill: #fff; }
.community .c-follow { margin: 1.2rem 0 .55rem; color: var(--muted); font-size: .74rem;
  text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
.social-row { display: flex; gap: .55rem; }
.social-row a { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--muted); transition: all .15s; }
.social-row a:hover { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.social-row svg { width: 18px; height: 18px; fill: currentColor; }

/* --- arcade footer --- */
.arc-footer { max-width: 1520px; margin: 2rem auto 0; padding: 1.7rem 1.6rem 2.6rem;
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .95rem; }
.arc-footer .af-brand img { height: 26px; width: auto; }
.arc-footer .af-links { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
.arc-footer .af-links a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.arc-footer .af-links a:hover { color: var(--accent); }
.arc-footer .af-note { color: var(--muted); font-size: .8rem; margin: 0; max-width: 740px; line-height: 1.5; }

/* --- responsive: collapse rails, games first --- */
@media (max-width: 1080px) {
  .arcade-layout { grid-template-columns: 1fr; gap: 1.4rem; padding: 1.4rem 1rem .5rem; }
  .rail { position: static; }
  .arcade-layout main.store { order: -1; }        /* games appear first */
  .rail-left { order: 1; }
  .rail-right { order: 0; }                         /* community card right under games */
  .rail-left .rail-brand { display: none; }         /* logo already in topbar on mobile */
  .rail-left .rail-tag { display: none; }
  .rail-left .rail-blurb { margin-top: 0; }
}

/* ===== Leaderboard page: overall XP board + arcade stats + game boards ===== */
.lb-page { max-width: 1560px; margin: 0 auto; padding: 2rem 1.6rem 1rem; }
.lb-h1 { font-size: 1.5rem; margin: 0 0 1rem; color: var(--title); }
.lb-cols { display: grid; gap: 1.9rem; align-items: start; }
/* The boards column is a <main>, so it inherits the site-wide 960px reading
   column — reset it or the two-column layout silently shrinks to 960px. */
.lb-cols main.lb-main { max-width: none; margin: 0; padding: 0; }
.lb-main { min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.side-h { font-size: 1rem; margin: 0 0 .7rem; color: var(--title); }
.side-block { min-width: 0; }
.lb-block { min-width: 0; }
.lb-block .panel { padding: 1.1rem 1.2rem; }

/* your standing card */
.you-card { padding: 1.1rem 1.2rem; }
.you-card .lvl-badge { width: 62px; height: 62px; }
.you-card .lvl-badge .lvl-num { font-size: 1.55rem; }
.you-next { margin: .55rem 0 0; font-size: .8rem; }

/* arcade stat tiles */
.stat-tiles { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .85rem .95rem; }
.stat .s-num { display: block; font-size: 1.5rem; font-weight: 800; color: var(--title); line-height: 1.1; }
.stat .s-lbl { display: block; margin-top: .25rem; font-size: .75rem; color: var(--muted); line-height: 1.35; }
.stat .s-lbl .muted { font-size: .95em; }

/* hall of fame: the arcade-wide top three, as podium cards */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.pod { display: flex; flex-direction: column; align-items: center; gap: .35rem; text-decoration: none; color: inherit;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 1rem .7rem 1.1rem; transition: .15s; }
.pod:hover { transform: translateY(-2px); border-color: var(--accent); }
.pod.p1 { border-color: color-mix(in srgb, var(--gold) 65%, var(--line)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 28%, transparent); }
.pod.is-me { background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); }
.pod-medal { font-size: 1.4rem; line-height: 1; }
.pod img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.pod.p1 img { width: 66px; height: 66px; border-color: var(--gold); }
.pod-name { font-weight: 700; font-size: .9rem; text-align: center; overflow-wrap: anywhere; }
.pod-xp { font-size: 1.15rem; font-weight: 800; color: var(--title); }
.pod-xp small { font-size: .62rem; color: var(--muted); font-weight: 700; letter-spacing: .06em; }

/* game board head: logo, title, Play, Discover */
h2.lb-head .lb-logo { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 9px; overflow: hidden;
  background: var(--tile-bg); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
h2.lb-head .lb-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-logo-emoji { font-size: .95rem; line-height: 1.05; text-align: center; word-break: break-all; }
.play-btn { font-size: .8rem; font-weight: 700; padding: .4rem .9rem; border-radius: 9px; white-space: nowrap;
  background: var(--accent); color: var(--accent-contrast); border: 1px solid var(--accent); text-decoration: none; transition: .15s; }
.play-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Kickstarter card + links (left column) */
.ks-card { padding: 1.1rem 1.2rem 1.2rem; }
.ks-cta { display: block; width: 100%; text-align: center; background: var(--gold); color: #3a2c00; font-weight: 700; }
.ks-cta:hover { filter: brightness(1.06); }
.lb-links { margin-top: 1rem; }

/* The page is a two-column grid: .lb-left (your standing + the overall
   board, then an "extras" block with the arcade's numbers, Kickstarter and the
   links) and .lb-main (the per-game boards). On a phone .lb-left becomes
   display:contents so its two halves become grid items in their own right and
   can be ordered around the boards — side, boards, extras — instead of pushing
   the boards below every link. */
.lb-left { min-width: 0; display: flex; flex-direction: column; gap: 1.5rem; }
.lb-extras { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }

/* the Hall of Fame column, beside the boards */
.lb-b .lb-cols { grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); }
.lb-b .lb-fame { display: flex; flex-direction: column; gap: 1.3rem; min-width: 0; }
.lb-b .fame-h { margin: 0; font-size: 1.15rem; color: var(--title); }
.lb-b .fame-panel { padding: 1.2rem; }

/* ===== responsive: one vertical column, boards first ===================== */
@media (max-width: 1180px) {
  .lb-page { padding: 1.4rem 1rem .5rem; }
  .lb-cols { grid-template-columns: 1fr !important; gap: 1.4rem; }
  .lb-left { display: contents; }
  .lb-b .lb-fame { order: 0; }
  .lb-main { order: 1; }
  .lb-extras { order: 2; }
  .lb-b .lb-fame { gap: 1.1rem; }
}
@media (max-width: 600px) {
  .stat-tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .s-num { font-size: 1.25rem; }
  .podium { grid-template-columns: 1fr; }
  .pod { flex-direction: row; justify-content: flex-start; gap: .7rem; padding: .7rem .9rem; }
  .pod img, .pod.p1 img { width: 40px; height: 40px; }
  .pod-name { text-align: left; flex: 1; }
  h2.lb-head .lb-logo { width: 32px; height: 32px; }
}

/* ===== topbar avatar menu: level chip always on, XP on hover/click ======== */
.usermenu { position: relative; }
.usermenu .me { text-decoration: none; }
.usermenu .lvl-chip { margin-left: .15rem; }
.um-pop { position: absolute; top: calc(100% + .55rem); right: 0; width: 258px; z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .95rem 1rem 1rem;
  box-shadow: 0 12px 34px rgba(0,0,0,.32); opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .13s, transform .13s, visibility .13s; }
.usermenu:hover .um-pop, .usermenu.open .um-pop, .usermenu:focus-within .um-pop {
  opacity: 1; visibility: visible; transform: translateY(0); }
.um-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.um-lvl { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; color: #3a2c00;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--gold) 85%, #fff) 0%, var(--gold) 70%);
  border: 1px solid color-mix(in srgb, var(--gold) 60%, #fff); }
.um-id { min-width: 0; display: flex; flex-direction: column; }
.um-id strong { font-size: .93rem; overflow-wrap: anywhere; }
.um-id .muted { font-size: .78rem; }
.um-next { margin: .45rem 0 .8rem; font-size: .74rem; }
.um-links { display: flex; flex-direction: column; gap: .1rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.um-links a { display: flex; align-items: center; gap: .5rem; padding: .42rem .5rem; border-radius: 8px;
  text-decoration: none; color: var(--text); font-size: .87rem; }
.um-links a:hover { background: var(--panel-2); }
.um-links .ri { font-size: .95rem; }
.um-out { margin: .6rem 0 0; border-top: 1px solid var(--line); padding-top: .6rem; }
.um-out button { width: 100%; }
@media (max-width: 600px) {
  .nav .me .uname { display: none; }
  .usermenu .lvl-chip { margin-left: .35rem; }   /* chip survives when the name is dropped */
  .um-pop { right: auto; left: 50%; transform: translate(-50%, -4px); }
  .usermenu:hover .um-pop, .usermenu.open .um-pop, .usermenu:focus-within .um-pop { transform: translate(-50%, 0); }
}

/* in-game bar: the level rides along into the game */
.game-bar .game-lvl { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; }
.game-bar .game-xp { color: var(--muted); font-size: .8rem; }
.game-bar .game-lvl:hover .game-xp { color: var(--text); }
@media (max-width: 600px) { .game-bar .game-xp { display: none; } }

/* ===== Krafting Krowns — Multiplayer: the Krown Points board ==============
   Eight boxes on /leaderboard (three all-time, three this month, two records)
   and the full board at /leaderboard/<game>. Everything here reuses the classes
   the page already ships — .podium/.pod, .panel, .stat-tiles, .lb — so the new
   block sits inside the same design rather than beside it. */

/* PODIUM EMPHASIS — global, and deliberately so. The medal emoji read as
   decoration: three small pictures in a row, with first place no louder than
   third. The position is now a numeral you can read across the room, and first
   place takes a gold card. The Hall of Fame on the left of the same page had
   exactly the same problem, so it gets exactly the same fix. */
.pod-rank { font-size: 1.9rem; font-weight: 900; line-height: 1; letter-spacing: -.02em; color: var(--muted); }
.pod.p1 .pod-rank { font-size: 2.6rem; color: #1a1205; }
.pod.p2 .pod-rank { color: #cfd6e6; }
.pod.p3 .pod-rank { color: #d8a06a; }
/* Silver and bronze are picked for a dark panel; on the cream light theme they
   wash out to nearly nothing, so both go a few stops darker. */
:root[data-theme="light"] .pod.p2 .pod-rank { color: #8b93a5; }
:root[data-theme="light"] .pod.p3 .pod-rank { color: #a0672c; }
.pod.p1 {
  background: linear-gradient(165deg, #f7d968 0%, #e8b53a 46%, #c08f16 100%);
  border-color: #ffe9a8;
  box-shadow: 0 10px 34px rgba(232,181,58,.28), inset 0 1px 0 rgba(255,255,255,.45);
}
.pod.p1 .pod-name, .pod.p1 .pod-xp { color: #1a1205; }
.pod.p1 .pod-xp small, .pod.p1 .pod-krowns { color: #5a4207; }
.pod.p1 img { border-color: rgba(26,18,5,.35); }
.pod.p1 .lvl-chip { background: #1a1205; color: #f7d968; border-color: #1a1205; }
.pod.p1.is-me { background: linear-gradient(165deg, #f7d968 0%, #e8b53a 46%, #c08f16 100%); }
.pod-krowns { font-size: .78rem; color: var(--muted); text-align: center; line-height: 1.45; }
.kk-unscored { font-size: .72rem; opacity: .75; font-style: italic; }

/* the two section headings inside the block */
.kk-row, .kk-season { display: flex; align-items: baseline; gap: .55rem; margin: 0 0 .6rem; }
.kk-season { align-items: center; gap: .6rem; }
.kk-row-season { margin-top: 1.3rem; }
.kk-row h3, .kk-season h3 { margin: 0; font-size: .82rem; letter-spacing: .09em; text-transform: uppercase; color: var(--title); }
.kk-sub { font-size: .78rem; color: var(--muted); }
.kk-countdown { font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
                color: #1a1205; background: var(--gold); border-radius: 999px; padding: 3px 10px; }

/* the two record boxes */
.kk-records { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.2rem 0 .2rem; }
.kk-rec { display: flex; align-items: center; gap: .8rem; color: inherit;
          background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: .85rem 1rem; }
.kk-rec-badge { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; font-size: 22px;
                display: flex; align-items: center; justify-content: center;
                background: var(--tile-bg); border: 1px solid var(--line); }
.kk-rec-body { display: flex; flex-direction: column; min-width: 0; }
.kk-rec-name { font-size: .68rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--gold); }
/* The records are all-time, and say so — they sit under the All time podium and
   above the month, and this is the line that stops anyone reading them as a
   monthly high score. */
.kk-rec-when { font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.kk-rec-when::before { content: '· '; }
.kk-rec-waiting { margin-top: .15rem; font-style: italic; }
.kk-rec-big { font-size: 1.15rem; font-weight: 800; color: var(--title); }
.kk-rec-sub { font-size: .76rem; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }

/* A full-width dashed sentence read as a caption, not a button. Short label,
   solid gold, sized to its words — the same shape as the Play button at the top
   of the block, which nobody has trouble clicking. */
.kk-cta-row { display: flex; justify-content: center; margin-top: 1.2rem; }
.kk-full-cta { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none;
               font-size: .9rem; font-weight: 800; letter-spacing: .01em; color: #1a1205;
               background: linear-gradient(180deg, #f7d968, #e0a913); border: 0; border-radius: 999px;
               padding: .6rem 1.4rem; box-shadow: 0 4px 14px rgba(232,181,58,.25); transition: .15s; }
.kk-full-cta:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* Competitive Score meter, in the full board's table */
.meter-wrap { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.meter { display: inline-flex; align-items: center; gap: .45rem; }
.meter .bar { display: inline-block; width: 62px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; vertical-align: middle; }
.meter .fill { display: block; height: 100%; background: linear-gradient(90deg, #5dc983, var(--gold), #e05c5c); }
.meter .val { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { white-space: nowrap; }
.meter.provisional { opacity: .55; }
.prov { display: inline-block; font-size: .68rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line);
        border-radius: 999px; padding: 1px 7px; background: var(--panel-2); white-space: nowrap; }
.pts { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

/* the [i] explainer — click, not hover, so it opens on a phone */
.kk-i { margin-left: .35rem; width: 16px; height: 16px; padding: 0; line-height: 14px; font-size: .68rem;
        font-weight: 800; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2);
        color: var(--muted); cursor: pointer; vertical-align: middle; }
.kk-i:hover, .kk-i[aria-expanded="true"] { border-color: var(--gold); color: var(--gold); }
.kk-explain { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 12px;
              padding: .9rem 1.1rem; margin-top: .9rem; background: var(--panel-2); font-size: .88rem; line-height: 1.6; }
.kk-explain h4 { margin: 0 0 .5rem; font-size: .95rem; color: var(--title); }
.kk-explain p { margin: 0 0 .6rem; color: var(--muted); }
.kk-explain ul { margin: 0 0 .6rem; padding-left: 1.1rem; color: var(--muted); }
.kk-explain li { margin-bottom: .15rem; }
.kk-explain b { color: var(--title); }
.kk-explain .mono { font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 700; }
.kk-explain-prov { border-top: 1px solid var(--line); padding-top: .6rem; margin-bottom: 0 !important; }

/* the full board page */
.lb .num { text-align: right; font-variant-numeric: tabular-nums; }
/* On a phone the Games and Win-rate columns collapse (.col-extra), so the same
   two numbers ride under the player's name instead of disappearing. */
.lb-mobile-sub { display: none; font-size: .74rem; color: var(--muted); margin-top: .2rem; }
.lbg-page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.6rem 1rem; }
.lbg-back { display: inline-block; margin: 0 0 .9rem; font-size: .85rem; color: var(--muted); text-decoration: none; }
.lbg-back:hover { color: var(--accent); }
.lbg-page .lb-block + .lb-block { margin-top: 1.6rem; }
.lbg-note { margin: 1rem 0 0; font-size: .8rem; color: var(--muted); line-height: 1.55; }
.lb .krowns { font-weight: 800; color: var(--title); }

@media (max-width: 600px) {
  .kk-records { grid-template-columns: 1fr; }
  .lb-mobile-sub { display: block; }
  /* On a 430px phone the number headings must not break mid-word
     ("Krow / n / Poin / ts"). Only they get nowrap — giving the whole row nowrap
     over-constrains the table and squeezes the player's name to one letter per
     line, which is worse than the problem. */
  .lbg-page .lb thead th { font-size: .68rem; }
  .lbg-page .lb thead th.num { white-space: nowrap; }
  .lbg-page .lb th, .lbg-page .lb td { padding: .5rem .35rem; }
  .lbg-page .lb .pname { gap: .35rem; }
  .lbg-page .lb .pname-txt { font-size: .82rem; word-break: normal; overflow-wrap: break-word; }
  .meter .bar { width: 34px; }
  .lbg-page { padding: 1.4rem 1rem .5rem; }
  /* Under 600px .pod becomes a horizontal row with .pod-name on flex:1. The two
     extra lines this block adds would fight it for space and squeeze the name to
     one letter per line, so they wrap onto their own full-width row. */
  .lb-block .pod { flex-wrap: wrap; }
  .lb-block .pod .pod-name { flex: 1 1 auto; min-width: 7rem; }
  .lb-block .pod .pod-xp { margin-left: auto; }
  .lb-block .pod-krowns { flex: 1 0 100%; text-align: left; }
  .pod.p1 .pod-rank { font-size: 2rem; }
}
