/* JoyFlock shared site chrome — header + footer.
   Single source of truth for the portal home and the four info pages.
   Loaded last on each page. Scoped to the non-game shell so #play keeps
   its in-game toolbar and its own footer-hiding behaviour. */

:root{
  --chrome-bg:#0b1020;
  --chrome-footer-bg:#0e1428;
  --chrome-line:#ffffff0c;
  --chrome-footer-line:#ffffff1a;
  --chrome-fade:#0b1020;
  --chrome-muted:#94a0be;
  --chrome-accent:#aab9ff;
  --chrome-active:#1b254a;
  --chrome-pad:2.5vw;
  --chrome-height:38px;
  /* Match the game-card corner in portal-editorial.css
     (#home .cards .game-card { border-radius:12px }); the header pills used
     to be 3px, which read as square corners next to the rounded covers. */
  --chrome-radius:12px;
}

/* ---------------------------------------------------------------- header */
/* ONE geometry for every shell state. The lobby, the game detail view and the
   four info pages all use the same height / padding / gap / nav rhythm, so
   opening a game never moves a single header element. */
body>.topbar{
  flex:0 0 auto;height:var(--chrome-height);gap:30px;
  /* Keep the brand indented, but let the right-hand cluster sit close to the
     edge: the old 2.5vw right padding wasted ~47px on a 1920px screen. */
  padding:0 16px 0 var(--chrome-pad);
  border-bottom:1px solid var(--chrome-line);background:var(--chrome-bg);
}
/* One type scale for every state; the old two-brand rule let the in-game
   header fall back to the 29px editorial size. */
body>.topbar .brand{font:900 19px Nunito,system-ui;letter-spacing:-1px;transition:transform .35s cubic-bezier(.2,.8,.2,1)}
body>.topbar .brand-mark{display:inline-block;color:#a8b8ff;margin-right:6px;transition:transform .5s cubic-bezier(.2,.8,.2,1),color .4s,text-shadow .4s}
body>.topbar nav{
  display:flex;align-self:stretch;align-items:center;gap:8px;
  flex:0 0 auto;min-width:0;white-space:nowrap;overflow:visible;
}
/* Fixed widths are sized for the longest (English) label. Switching the
   language swaps text only: no link grows, shrinks or changes position.
   The nav has exactly two links — Games and Shop (the points shop). Both
   labels are short enough to share one width; :last-child is part of the
   base selector so neither pill can stretch when the locale changes.
   Membership and support stays in the footer. */
body>.topbar nav a,
body>.topbar nav a:last-child{
  box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;
  align-self:center;height:24px;padding:0 12px;border-radius:var(--chrome-radius);border-bottom:0;
  white-space:nowrap;color:var(--chrome-muted);font-size:12px;font-weight:700;
}
body>.topbar nav a{width:96px}
body>.topbar nav a:nth-child(2){width:96px}
body>.topbar nav a:hover{color:#e7eeff;background:#ffffff0a}
body>.topbar nav a.active,
body>.topbar nav .active{color:#fff;background:var(--chrome-active);border-bottom:0}
body>.topbar .top-note{display:none}
/* Language picker: two thirds of its old 112px width. Scoped through
   .top-actions so this wins over the looser min-widths in portal.css /
   portal-editorial.css / legal.css on every shell page. The narrower box
   keeps a smaller side padding so "English" still fits beside the native
   arrow instead of being ellipsised. */
body>.topbar .top-actions .portal-language{
  box-sizing:border-box;width:75px;min-width:75px;max-width:75px;
  margin-left:0!important;flex:0 0 auto;height:24px;
  font:inherit;font-size:11px;font-weight:700;color:#e3eaff;
  background:var(--chrome-active);border:1px solid #46518a;border-radius:var(--chrome-radius);padding:0 5px;
}
body>.topbar .portal-language:focus-visible{outline:2px solid #a8b8ff;outline-offset:3px}

/* ---------------------------------------------------------------- footer */
body:not(.playing)>footer{
  position:relative;z-index:2;flex:0 0 auto;
  display:flex;align-items:center;gap:14px;
  width:100%;margin:0;padding:7px var(--chrome-pad);
  border-top:1px solid var(--chrome-footer-line);background:var(--chrome-footer-bg);
  box-shadow:0 -10px 30px #00000055;
  color:#6f7d9c;font-size:10px;letter-spacing:normal;text-transform:none;
}
body:not(.playing)>footer::before{
  content:'';position:absolute;left:0;right:0;bottom:100%;height:16px;
  background:linear-gradient(transparent,var(--chrome-fade));pointer-events:none;
}
body:not(.playing)>footer .brand{font:900 15px Nunito,system-ui;letter-spacing:-1px;color:#a4b1d4}
body:not(.playing)>footer span{margin-left:6px}
/* Membership & support joins Terms / Privacy / Contact here. Wrapping keeps
   the longer label from pushing the footer past a narrow viewport. */
body:not(.playing)>footer div{margin-left:auto;display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px 14px}
body:not(.playing)>footer div a:hover{color:var(--chrome-accent)}
body.playing>footer{display:none}

/* ------------------------------------------------------------ responsive */
@media(max-width:920px){
  body>.topbar{padding:0 16px;gap:18px}
  body>.topbar nav a{width:88px}
  body>.topbar nav a:nth-child(2){width:88px}
  body:not(.playing)>footer{padding:7px 16px}
}
@media(max-width:600px){
  :root{--chrome-height:34px}
  body>.topbar{height:var(--chrome-height);padding:0 12px;gap:10px}
  body>.topbar .brand{font-size:17px}
  body>.topbar nav{gap:2px}
  body>.topbar nav a,
  body>.topbar nav a:last-child{font-size:11px;height:20px;padding:0 6px}
  body>.topbar nav a{width:72px}
  /* "Shop / 商城" is short: keep the second link narrow so the points pill
     and the account cluster still fit on a small phone. */
  body>.topbar nav a:nth-child(2){width:60px}
  body>.topbar .top-actions .portal-language{width:64px;min-width:64px;max-width:64px;height:22px;font-size:10px;padding:0 3px}
  body:not(.playing)>footer{padding:8px 12px;flex-wrap:wrap;gap:8px;font-size:10px}
  body:not(.playing)>footer div{margin-left:0;width:100%;gap:6px 16px}
}
/* Very small phones: the wordmark is the only flexible item. Keep the ✦
   logo clickable but drop the text, so Games + Shop, the language picker and
   the points pill all stay inside the viewport without a horizontal scroll. */
@media(max-width:480px){
  body>.topbar{gap:3px;padding:0 4px}
  body>.topbar .brand{font-size:0}
  body>.topbar .brand-mark{font-size:19px;margin-right:0}
  /* Tighten the whole right cluster, not just its reserved box: the child
     pills are fixed-width and would otherwise still stick out of the box. */
  body>.topbar .top-actions{gap:6px;width:266px}
  body>.topbar .top-actions .portal-language{width:58px;min-width:58px;max-width:58px;font-size:9px;padding:0 2px}
  body>.topbar .top-actions .jp-pill{width:72px;min-width:72px;gap:2px;padding:3px 5px;font-size:10px}
  /* A seven-character balance ("100,000") needs a smaller star, a tighter
     gap and 11px digits to stay inside the 72px pill at 390px. Shrinking the
     contents keeps the reserved cluster width (and the first frame) stable. */
  body>.topbar .top-actions .jp-mark{width:15px;height:15px}
  body>.topbar .top-actions .jp-amount{font-size:11px}
}

/* ------------------------------------------- unified header right cluster */
/* Every shell page renders the same right-hand group: language + account.
   #portal-controls is placed BEFORE this group in the flex order: when the
   game view reveals it (even at zero width) it can no longer eat a trailing
   gap and pull the account buttons 20px to the left. */
.topbar .top-actions{
  /* Progressive HTML rendering used to paint the language select alone at the
     far right before the two account buttons were parsed, then shove it ~196px
     left. Reserving the final width keeps the cluster anchored on frame one.
     75 (select) + 2*88 (buttons) + 2*10 (gaps) = 271. */
  order:2;margin-left:auto;display:flex;align-items:center;gap:10px;
  flex:0 0 auto;min-width:0;width:373px;
}
.topbar #portal-controls{order:1}
.topbar .top-actions .portal-language{margin-left:0!important}
/* The date was removed from the header. Keep this guard for any stale cached
   HTML that still document.write()s it, so it can never shift the group. */
.topbar .top-date,
.topbar .top-note{display:none!important}
/* Fixed widths again: "Sign up" is the longest label, so 88px covers both
   languages and both buttons stay put on a locale switch. */
.chrome-account{
  position:relative;box-sizing:border-box;width:88px;min-width:88px;
  display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;
  height:24px;padding:0 10px;border-radius:var(--chrome-radius);
  border:1px solid #6a7ccc;background:#2c3a72;color:#eaf0ff;
  font:inherit;font-size:11px;font-weight:700;line-height:1;white-space:nowrap;
  cursor:pointer;box-shadow:none;overflow:hidden;
}
.chrome-account>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chrome-account:hover{background:#3a4b91;border-color:#9db0ff}
.chrome-account:focus-visible{outline:2px solid #a8b8ff;outline-offset:3px}
.chrome-account[hidden]{display:none!important}
/* Sign-in and sign-up are two distinct entries: outlined secondary button. */
.chrome-account.chrome-register{background:#ffffff08;border-color:#4a5790;color:#c3cff0}
.chrome-account.chrome-register:hover{background:#ffffff16;border-color:#8d9dbf;color:#fff}
/* Signed in: retire the second entry from the layout entirely. An invisible
   but still 88px-wide slot used to leave a dark hole between the nickname and
   the points pill. display:none keeps the button in the DOM so a later
   sign-out can reveal it again; site-points.css shrinks the reserved cluster
   width by the same amount, so no header element shifts on frame one. */
.chrome-account.chrome-account-gone{display:none!important}
/* Once signed in the first entry shows the nickname. */
body.chrome-signed>.topbar .chrome-account{background:#2c3a72;border-color:#6a7ccc;color:#eaf0ff}
/* A visitor with no cached account state yet (first load on this origin, or
   localStorage cleared) must not be told "Sign in" while /api/me is in
   flight. A neutral shimmer fills the reserved slot until the server answers;
   the button geometry never changes. */
.chrome-account.chrome-account-pending>span{visibility:hidden}
.chrome-account.chrome-account-pending::after{
 content:"";position:absolute;left:50%;top:50%;width:38px;height:6px;
 transform:translate(-50%,-50%);border-radius:3px;pointer-events:none;
 background:linear-gradient(90deg,#ffffff1a 0%,#ffffff55 50%,#ffffff1a 100%);
 background-size:200% 100%;animation:chrome-account-shimmer 1.1s linear infinite;
}
@keyframes chrome-account-shimmer{from{background-position:100% 0}to{background-position:-100% 0}}
/* In-game controls: the account slot is now the one shared header button.
   The floating language/sound cluster is gone at every viewport width —
   the shared header already owns language, and sound lives in the game.
   Its DOM stays (the iframe bridge reports into it) but it never renders,
   so it cannot eat a trailing gap or shift the right-hand cluster. */
body.playing>.topbar #portal-controls [data-control=account]{display:none!important}
body.playing>.topbar #portal-controls{display:none!important}

/* ------------------------------------------------------- account dialog */
.chrome-auth{
  box-sizing:border-box;width:min(420px,calc(100vw - 32px));max-height:calc(100dvh - 40px);
  overflow-y:auto;overscroll-behavior:contain;
  padding:30px 30px 26px;border:1px solid #3b4a80;border-radius:12px;
  background:linear-gradient(165deg,#1c2647 0%,#141b30 55%,#111827 100%);
  color:#eaf0ff;box-shadow:0 30px 80px #000b,inset 0 1px 0 #ffffff14;
  font:14px/1.6 Inter,"Microsoft YaHei",system-ui,sans-serif;
}
.chrome-auth::backdrop{background:#050812c4;backdrop-filter:blur(5px)}
.chrome-auth [hidden]{display:none!important}
.chrome-auth-close{
  position:absolute;top:16px;right:16px;width:28px;height:28px;padding:0;
  display:grid;place-items:center;
  border:1px solid #46518a;border-radius:6px;background:#ffffff08;color:#b8c6e6;
  font:inherit;font-size:18px;line-height:1;cursor:pointer;transition:background .18s,color .18s,border-color .18s;
}
.chrome-auth-close:hover{background:#ffffff16;color:#fff;border-color:#8d9dff}
.chrome-auth-brand{
  display:flex;align-items:center;gap:7px;margin:0 0 14px;
  color:#aab9ff;font:800 13px Nunito,system-ui;letter-spacing:.3px;
}
.chrome-auth-mark{font-size:16px;color:#c3ceff}
.chrome-auth h2{margin:0 0 6px;font-size:23px;font-weight:800;letter-spacing:-.4px;line-height:1.3}
.chrome-auth-note{margin:0 0 20px;color:#9dabd0;font-size:12.5px;line-height:1.7}
/* Separate dialogs, no tabs and no dual-action form. The quiet link below
   swaps one independent dialog for the other. */
.chrome-auth-switch{
  margin:18px 0 0;padding-top:16px;border-top:1px solid #ffffff12;
  text-align:center;color:#8d9dbf;font-size:12.5px;
}
.chrome-auth-switch a{
  color:#b7c5ff;font-weight:700;text-decoration:none;
  border-bottom:1px solid #6a7ccc99;padding-bottom:1px;
}
.chrome-auth-switch a:hover{color:#fff;border-bottom-color:#fff}
.chrome-auth[data-kind="register"] .chrome-auth-note{margin-bottom:16px}
.chrome-auth[data-kind="register"] .chrome-auth-form{gap:11px}
.chrome-auth-form{display:flex;flex-direction:column;gap:14px}
.chrome-auth-field{display:flex;flex-direction:column;gap:6px;color:#aab8d8;font-size:11.5px;font-weight:600}
.chrome-auth-field input{
  height:42px;padding:0 13px;border:1px solid #3a4880;border-radius:7px;
  background:#0d1428;color:#eaf0ff;font:inherit;font-size:14px;font-weight:400;
  transition:border-color .18s,box-shadow .18s;
}
.chrome-auth-field input::placeholder{color:#5c6b92}
.chrome-auth-field input:hover{border-color:#4d5da0}
.chrome-auth-field input:focus{outline:none;border-color:#8d9dff;box-shadow:0 0 0 3px #8d9dff26}
.chrome-auth-error{margin:0;color:#ff9d9d;font-size:12px}
.chrome-auth-error:empty{display:none}
.chrome-auth-error:not(:empty){margin-top:-4px}
.chrome-auth-submit{
  width:100%;height:44px;margin-top:2px;border:0;border-radius:7px;
  background:linear-gradient(135deg,#5869d8,#7a5bd8);color:#fff;
  font:inherit;font-size:14px;font-weight:800;cursor:pointer;
  box-shadow:0 6px 18px #4a58c040;transition:filter .18s,transform .18s;
}
.chrome-auth-submit:hover{filter:brightness(1.12);transform:translateY(-1px)}
.chrome-auth-submit:disabled{opacity:.6;cursor:default;transform:none;filter:none}
.chrome-auth-signed{display:flex;flex-direction:column;align-items:center;gap:12px;padding:10px 0 4px;text-align:center}
.chrome-auth-avatar{
  width:52px;height:52px;display:grid;place-items:center;border-radius:22%;
  background:linear-gradient(135deg,#5869d8,#7a5bd8);color:#fff;font:800 22px Nunito,system-ui;
}
.chrome-auth-who{margin:0;color:#e2e9ff;font-size:14px;font-weight:700}
.chrome-auth-signout{
  width:100%;height:38px;border:1px solid #46518a;border-radius:7px;
  background:#ffffff08;color:#c8d3ff;font:inherit;font-size:13px;font-weight:700;cursor:pointer;
}
.chrome-auth-signout:hover{background:#ffffff14;border-color:#8d9dff}
.chrome-vip{width:100%;text-align:left;border-top:1px solid #ffffff14;padding-top:14px}
.chrome-vip h3{margin:0;color:#f3d891;font-size:17px}
.chrome-vip p{margin:6px 0 12px;color:#9dabd0;font-size:12px;line-height:1.5}
.chrome-vip-plans{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.chrome-vip-plans button{display:flex;flex-direction:column;align-items:flex-start;gap:3px;min-width:0;padding:14px;border:1px solid #6676b7;border-radius:10px;background:#263354;color:#eaf0ff;font:inherit;cursor:pointer;text-align:left;transition:background .18s,border-color .18s}
.chrome-vip-plans button:hover:enabled{background:#34466e;border-color:#e9cd85}
.chrome-vip-plans button:disabled{opacity:.65;cursor:default}
.chrome-vip-plans strong{font-size:26px;color:#f3d891;line-height:1.4;white-space:nowrap}
.chrome-vip-plans small,.chrome-vip-plans span{font-size:11px;font-weight:400;color:#b7c4df}
/* The billing period is rendered inside <strong> in site-account.js, so it
   shares the price line instead of taking a whole flex row of its own. No
   margin here: the price reads "$9 USD/月" with no space around the slash. */
.chrome-vip-plans .vip-period{vertical-align:baseline;white-space:nowrap}
.chrome-vip-plans em{margin-top:6px;font-size:12px;font-weight:700;font-style:normal}
.chrome-vip>small{display:block;font-size:11px;color:#8d9dbf;line-height:1.6}
.chrome-vip a{color:#bdcaff}
.chrome-vip-membership{display:flex;flex-direction:column;gap:5px;margin-top:10px;padding:12px;border:1px solid #62719a;border-radius:8px;background:#ffffff07;font-size:12px;color:#b7c4df}
.chrome-vip-membership strong{color:#f3d891;font-size:15px}
.chrome-vip-cancel{align-self:flex-start;margin-top:6px;padding:6px 12px;border:1px solid #6676b7;border-radius:6px;background:#ffffff0a;color:#cdd9f5;font:inherit;font-size:11px;cursor:pointer}
.chrome-vip-cancel:hover:enabled{background:#34466e;border-color:#e9cd85}
.chrome-vip-cancel:disabled{opacity:.55;cursor:default}
@media(max-width:760px){
  .account-extra{display:none}
  /* Narrow header keeps one entry; registration is reachable from the
     sign-in dialog's switch link. 75 + 88 + 92 + 2*10 = 275 (fullscreen pill included). */
  .topbar .top-actions{width:275px}
  .topbar .chrome-register{display:none!important}
}
@media(max-width:600px){
  /* 64 (select) + 76 (button) + 42 (fullscreen icon) + 2*6 = 194. */
  .topbar .top-actions{gap:6px;width:194px}
  .chrome-account{width:76px;min-width:76px;height:22px;padding:0 6px;font-size:10px}
  .chrome-auth{padding:24px 20px 22px;border-radius:10px}
  .chrome-auth h2{font-size:20px}
  .chrome-auth-note{margin-bottom:16px}
  .chrome-auth-switch{margin-top:14px;padding-top:12px}
}
/* Short viewports: keep the whole register form on one screen instead of
   forcing a scroll inside the dialog. */
@media(max-height:700px){
  .chrome-auth{padding:20px 20px 18px}
  .chrome-auth-brand{margin-bottom:10px}
  .chrome-auth h2{font-size:20px}
  .chrome-auth-note{margin-bottom:14px}
  .chrome-auth-switch{margin-top:12px;padding-top:10px}
  .chrome-auth-form{gap:10px}
  .chrome-auth-field input{height:38px}
  .chrome-auth-submit{height:40px}
}

/* ------------------------------------------------- first-paint language */
/* Both translations live in the HTML. A synchronous <head> bootstrap sets
   data-locale before the first paint, so no JS text swap is ever visible. */
html[data-locale="en"] .lang-cn,
html[data-locale="zh"] .lang-en{display:none!important}
html[data-locale="en"] article[lang="zh-CN"],
html[data-locale="zh"] article[lang="en"]{display:none!important}

/* ---------------------------------------------------------------------------
   NO portrait frames at all (2026-11-16): the signed-in account dialog
   portrait loses its border, radius and shadow as well. Its background
   image is set inline by site-account.js, so background-image is left
   alone deliberately - overriding it would hide the uploaded avatar.
   --------------------------------------------------------------------------- */
.chrome-auth-avatar{
  border:0!important;box-shadow:none!important;
  background-color:transparent!important;border-radius:0!important;
}
[data-frame="gold"]::after,[data-frame="cloud"]::after,[data-frame="night"]::after{
  content:none!important;background-image:none!important;
}
.avatar-frame{display:none!important}
