/* ============================================================================
   Gridrop — SHARED GAME HEADER (single source of truth).
   Every game page renders the same top bar via header.js into <div id="grhead">.
   This file is the ONE place to re-skin the header / account pill / controls —
   a future theme or purchasable cosmetic bundle overrides these rules once and
   it flows to every game. All rules are scoped under .grhead so they never
   collide with a page's own classes.
   Colours come from css/tokens.css (--cyan, --card, --line, --mut, --accent,
   --txt); hard fallbacks are baked in so the bar looks right even if a page
   loads before the tokens.
   ============================================================================ */

.grhead{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:2px 2px 12px; direction:ltr;               /* brand + numbers stay LTR even in Arabic */
  font-family:'Sora','Inter',system-ui,sans-serif;
}
body.ar .grhead{ direction:ltr; }

/* ---- brand (logo + wordmark), clickable → home ---- */
.grhead .brand{
  display:flex; align-items:center; gap:9px;
  cursor:pointer; user-select:none; -webkit-tap-highlight-color:transparent;
  transition:opacity .15s; flex:0 0 auto;   /* never shrink so the wordmark image can't overflow the controls */
}
.grhead .brand:hover{ opacity:.82; }
.grhead .brand:active{ opacity:.6; }
.grhead .brand:focus-visible{ outline:2px solid var(--cyan,#1FE9DD); outline-offset:3px; border-radius:8px; }
.grhead .brand .g{
  width:30px; height:30px; flex:0 0 auto; display:block; border-radius:7px;
  filter:drop-shadow(0 0 5px rgba(10,182,212,.35));
}
.grhead .brand .wm{
  height:17px; width:auto; display:inline-block; vertical-align:middle;
  filter:drop-shadow(0 0 7px rgba(10,182,212,.5));
}

/* ---- right control cluster ---- */
.grhead .topr{ display:flex; align-items:center; gap:8px; flex:0 0 auto; }

/* language pill (EN / ع) */
.grhead .langs{
  display:flex; gap:4px; background:var(--card,#101922);
  border:1px solid var(--line,#20343d); border-radius:999px; padding:3px; flex:0 0 auto;
}
.grhead .langs button{
  font:inherit; font-weight:800; font-size:12px; color:var(--mut,#7fa6ad);
  background:none; border:0; padding:5px 11px; border-radius:999px; cursor:pointer;
  transition:.15s; line-height:1;
}
.grhead .langs button.on{ background:linear-gradient(135deg,var(--cyan,#1FE9DD),var(--accent,#0AB6D4)); color:#04221f; }
.grhead .langs.locked{ opacity:.4; pointer-events:none; }

/* help "?" button */
.grhead .ht-help{
  width:34px; height:34px; flex:0 0 auto; display:grid; place-items:center; padding:0;
  border-radius:50%; border:1.5px solid color-mix(in srgb,var(--cyan,#0AB6D4) 50%,transparent);
  background:color-mix(in srgb,var(--cyan,#0AB6D4) 10%,transparent);
  color:var(--cyan,#1FE9DD); font-weight:900; font-size:16px; cursor:pointer; transition:.15s;
  font-family:inherit; line-height:1;
}
.grhead .ht-help:hover{ background:var(--cyan,#0AB6D4); color:#04181c; }
/* label variant (howto.js re-labels it as the tutorial-replay affordance) */
.grhead .ht-help.htlbl{ width:auto; border-radius:999px; padding:0 12px; gap:6px; }
.grhead .ht-help.htlbl .htlbl-t{ font-size:12px; font-weight:800; white-space:nowrap; letter-spacing:.2px; }

/* sound toggle */
.grhead .sndbtn{
  width:34px; height:34px; flex:0 0 auto; display:grid; place-items:center; padding:0;
  background:var(--card,#101922); border:1px solid var(--line,#20343d); border-radius:999px;
  color:var(--cyan,#1FE9DD); cursor:pointer; transition:.15s;
}
.grhead .sndbtn:hover{ border-color:var(--cyan,#1FE9DD); }
.grhead .sndbtn.off{ color:var(--mut,#7fa6ad); }
.grhead .sndbtn svg{ width:18px; height:18px; }

/* ---- account pill + dropdown (self-contained, Supabase-backed) ---- */
.grhead .authwrap{ position:relative; display:inline-flex; align-items:center; flex:0 0 auto; }
.grhead .authpill{
  display:inline-flex; align-items:center; gap:6px; font:inherit; font-size:12px; font-weight:800;
  letter-spacing:.02em; color:var(--cyan,#1FE9DD); background:rgba(31,233,221,.10);
  border:1px solid var(--line,#20343d); border-radius:999px; padding:6px 12px; cursor:pointer;
  text-decoration:none; white-space:nowrap; line-height:1; transition:border-color .15s,background .15s;
}
.grhead .authpill:hover{ border-color:var(--cyan,#1FE9DD); background:rgba(31,233,221,.18); }
.grhead .authpill svg{ width:15px; height:15px; flex:0 0 auto; }
.grhead .authpill.me{ padding:4px 10px 4px 4px; color:var(--txt,#eaf6f8); }
.grhead .authpill .ava{
  width:23px; height:23px; border-radius:50%; background:linear-gradient(135deg,#1FE9DD,#0AB6D4);
  color:#042a2f; font-weight:900; font-size:12px; display:flex; align-items:center; justify-content:center; flex:0 0 auto;
}
.grhead .authpill .anm{ max-width:88px; overflow:hidden; text-overflow:ellipsis; }
.grhead .authpill .car{ width:9px; height:9px; opacity:.7; }
.grhead .authmenu{
  position:absolute; top:calc(100% + 7px); inset-inline-end:0; background:#0e1c22;
  border:1px solid var(--line,#20343d); border-radius:12px; padding:5px; min-width:158px;
  box-shadow:0 16px 38px -14px #000; display:none; flex-direction:column; gap:2px; z-index:200;
}
.grhead .authmenu.on{ display:flex; }
.grhead .authmenu a,.grhead .authmenu button{
  font:inherit; font-size:13px; font-weight:700; color:var(--txt,#eaf6f8); background:none; border:0;
  border-radius:8px; padding:9px 12px; text-align:start; cursor:pointer; text-decoration:none; white-space:nowrap;
}
.grhead .authmenu a:hover,.grhead .authmenu button:hover{ background:rgba(255,255,255,.07); }
.grhead .authmenu .out{ color:#ff6b6b; }
.grhead .authmenu .em{
  font-size:11px; font-weight:600; color:var(--muted,#7fa6ad); padding:6px 12px 4px;
  border-bottom:1px solid var(--line,#20343d); margin-bottom:3px; max-width:200px; overflow:hidden; text-overflow:ellipsis;
}

/* fullscreen button (fs.js docks .fsgrp here) — keep it compact inside the bar */
.grhead .fsgrp{ display:inline-flex; align-items:center; gap:7px; flex:0 0 auto; }

/* ============================================================================
   Responsive: keep the bar to ONE short row on phones so it never grows taller
   and squeezes a game's play area. Progressive collapse as width shrinks.
   ============================================================================ */
@media (max-width:520px){
  .grhead{ gap:8px; padding-bottom:10px; }
  .grhead .topr{ gap:6px; }
  .grhead .langs button{ padding:5px 9px; }
}
@media (max-width:430px){
  /* phone: the full control set (incl. fullscreen) + wordmark won't fit one row,
     so drop the wordmark — the "G" mark still carries the brand (same tradeoff
     play.html makes in landscape). Sign-in collapses to just its icon. */
  .grhead .brand .wm{ display:none; }
  .grhead .authpill .anm,.grhead .authpill .txt{ display:none; }
  .grhead .authpill{ padding:6px 9px; }
  .grhead .authpill.me{ padding:4px; }
  .grhead .ht-help,.grhead .sndbtn{ width:31px; height:31px; }
}
@media (max-width:360px){
  /* very narrow: shrink the mark + tighten gaps so controls still fit one row */
  .grhead .brand .g{ width:26px; height:26px; }
  .grhead{ gap:6px; }
  .grhead .topr{ gap:5px; }
  .grhead .langs button{ padding:5px 8px; font-size:11.5px; }
}
