/*
 * Coquille de jeu BARÆ.
 * Le thème des pages dépend exclusivement des variables --game-*.
 * La navigation inférieure est fournie par BARÆ : aucune règle ici ne la redessine.
 */
:root {
  --game-bg: #f6f4ef;
  --game-surface: #ffffff;
  --game-text: #252b2c;
  --game-muted: #687574;
  --game-accent: #335d98;
  --game-accent-ink: #ffffff;
  --game-border: #deddd6;
  --game-heading-font: Georgia, "Times New Roman", serif;
  --game-body-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding-bottom: calc(166px + env(safe-area-inset-bottom, 0px)) !important;
  background: var(--game-bg);
  color: var(--game-text);
  font: 16px/1.55 var(--game-body-font);
  -webkit-text-size-adjust: 100%;
}
/* The later platform stylesheet also reserves its nav: keep the ad row too. */
body.barae-game-platform:not(.barae-game-menu) {
  padding-bottom: calc(166px + env(safe-area-inset-bottom, 0px)) !important;
}
[hidden] { display: none !important; }
.bg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.bg-skip {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 1000;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 2px solid var(--game-accent);
  border-radius: 10px;
  background: var(--game-surface);
  color: var(--game-text);
  font: 700 14px/1.4 var(--game-body-font);
  text-align: center;
  text-decoration: none;
  transform: translate(-50%, -200%);
  pointer-events: none;
}
.bg-skip:focus { transform: translate(-50%, 0); pointer-events: auto; }
.bg-skip:focus-visible { outline: 3px solid var(--game-accent); outline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; }
.bg-shell a { color: inherit; }
.bg-shell :is(a, button, input, select, textarea):focus-visible,
.barae-game-menu :is(a, button):focus-visible {
  outline: 3px solid var(--game-accent);
  outline-offset: 4px;
}
.bg-shell {
  width: 100%;
  max-width: 620px;
  min-width: 0;
  margin-inline: auto;
  overflow-wrap: anywhere;
}
body[data-view="daily"] #game-stage { margin-inline: 24px; }
body[data-view="daily"] #start-game { display: flex; margin: 20px auto 24px; }
body[data-view="daily"] #game-result { padding: 24px; }
.bg-shell > #network-error { margin-inline: 24px; }
.bg-shell > #account-conflict { margin-inline: 24px; }
.bg-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 92px;
  padding: max(20px, env(safe-area-inset-top, 0px)) 24px 16px;
}
.bg-game-header > a { display: inline-flex; align-items: center; min-height: 44px; }
.bg-game-header img { display: block; width: 190px; max-width: 100%; height: auto; }
.bg-game-header svg { display: block; max-width: 100%; }
.bg-page-head { padding: 12px 24px 0; }
.bg-page-head h1 {
  margin: 0 0 12px;
  font: 400 clamp(28px, 7vw, 36px)/1.14 var(--game-heading-font);
  letter-spacing: -.035em;
}
.bg-page-head p { margin: 0; color: var(--game-muted); font-size: 14px; line-height: 1.6; }
.bg-page-head > a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
  color: var(--game-muted);
  font-size: 13px;
  text-decoration: none;
}
.bg-day-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 14px;
  padding: 0 24px 16px;
  color: var(--game-muted);
  font-size: 13px;
  line-height: 1.5;
}
.bg-day-label > span { color: var(--game-text); font-weight: 600; }
.bg-day-label > time { font-variant-numeric: tabular-nums; }
.bg-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--game-muted);
  font-size: 13px;
  text-decoration: none;
}
.bg-page-content { padding: 24px; }
.bg-page-content > :first-child { margin-top: 0; }
.bg-page-content > :last-child { margin-bottom: 0; }
.bg-page-content h2 {
  margin: 28px 0 14px;
  font: 400 25px/1.2 var(--game-heading-font);
  letter-spacing: -.02em;
}
.bg-page-content h3 { margin: 20px 0 8px; font-size: 17px; line-height: 1.35; }
.bg-card {
  min-width: 0;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--game-border);
  border-radius: 18px;
  background: var(--game-surface);
}
.bg-card h2, .bg-card h3 { margin-top: 0; }
.bg-card > :last-child { margin-bottom: 0; }
.bg-message { margin: 14px 0; font-size: 14px; line-height: 1.65; }
.bg-message:empty { display: none; }
.bg-error { color: #9a2944; }
.bg-message.bg-error {
  padding: 12px 14px;
  border-left: 4px solid #9a2944;
  border-radius: 4px;
  background: #fff0f3;
}
.bg-action { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 22px; }
.bg-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 140px;
  min-height: 48px;
  max-width: 100%;
  padding: 12px 20px;
  border: 1px solid var(--game-accent);
  border-radius: 12px;
  background: var(--game-accent);
  color: var(--game-accent-ink) !important;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  transition: opacity 140ms ease;
}
.bg-button:hover:not(:disabled) { opacity: .9; }
.bg-button:disabled, .bg-button[aria-disabled="true"] { opacity: .55; cursor: default; }
.bg-button[aria-busy="true"] { cursor: wait; }
.bg-button svg { width: 19px; height: 19px; flex: none; }
.bg-quiet { color: var(--game-muted); font-size: 13px; line-height: 1.6; }
.bg-empty { padding: 28px 22px; text-align: center; }
.bg-empty h2, .bg-empty h3 { margin: 0 0 10px; }
.bg-empty p { margin: 0; color: var(--game-muted); font-size: 14px; }
.bg-empty .bg-button { margin-top: 22px; }
.bg-result { text-align: center; }
.bg-result h1, .bg-result h2 { margin: 0 0 12px; font-family: var(--game-heading-font); }
.bg-result-score {
  display: block;
  margin: 12px 0;
  color: var(--game-accent);
  font: 400 clamp(42px, 12vw, 64px)/1.15 var(--game-heading-font);
  font-variant-numeric: tabular-nums;
}
.bg-result-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 18px;
  margin-top: 20px;
  font-size: 14px;
}
.bg-result-links a { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: 4px; }
.bg-profile-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bg-stat {
  min-width: 0;
  padding: 18px 14px;
  border: 1px solid var(--game-border);
  border-radius: 14px;
  background: var(--game-surface);
}
.bg-stat strong { display: block; font: 400 30px/1.15 var(--game-heading-font); font-variant-numeric: tabular-nums; }
.bg-stat span, .bg-stat small { display: block; margin-top: 6px; color: var(--game-muted); font-size: 12px; }
.bg-data { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.4; }
.bg-data th, .bg-data td { padding: 14px 8px; border-bottom: 1px solid var(--game-border); text-align: left; vertical-align: middle; }
.bg-data th { color: var(--game-muted); font-size: 11px; font-weight: 600; }
.bg-data th:first-child, .bg-data td:first-child { padding-left: 0; }
.bg-data th:last-child, .bg-data td:last-child { padding-right: 0; text-align: right; }
.bg-data tr[data-me] { background: var(--game-bg); font-weight: 700; }
.bg-data td { overflow-wrap: anywhere; }
.bg-data img { width: 30px; height: 30px; max-width: 100%; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 7px; }
.bg-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.bg-calendar > a, .bg-calendar > span:not(.bg-weekday):not(.bg-calendar-blank) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  padding: 7px 2px;
  border: 1px solid var(--game-border);
  border-radius: 9px;
  background: var(--game-surface);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.bg-calendar small { display: block; font-size: 10px; }
.bg-weekday { padding: 3px 0 8px; color: var(--game-muted); font-size: 11px; text-align: center; }
.bg-calendar-blank { min-width: 0; }
.bg-calendar [data-state="future"] { color: var(--game-muted); background: transparent; border-style: dashed; }
.bg-calendar [data-state="won"], .bg-calendar [data-state="caught_up"] { background: #e8f2e5; border-color: #b9cfb2; color: #2d5e3a; }
.bg-calendar [data-state="failed"] { background: #fff0f3; border-color: #e5b2bf; color: #8c2941; }
.bg-calendar [aria-current="date"] { outline: 2px solid var(--game-accent); outline-offset: 1px; font-weight: 700; }
.bg-calendar a:hover { border-color: var(--game-accent); }
.bg-calendar-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; color: var(--game-muted); font-size: 11px; }
.bg-calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bg-history { margin: 0; padding: 0; list-style: none; }
.bg-history-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 15px 0;
  border-bottom: 1px solid var(--game-border);
  font-size: 14px;
  text-decoration: none;
}
.bg-history-copy { min-width: 0; }
.bg-history-copy strong { display: block; font-weight: 600; }
.bg-history-copy small { display: block; margin-top: 4px; color: var(--game-muted); font-size: 12px; }
.bg-history-score { flex-shrink: 0; color: var(--game-accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.bg-status { display: inline-block; margin-top: 5px; color: var(--game-muted); font-size: 12px; }
.bg-status[data-state="won"], .bg-status[data-state="caught_up"] { color: #2d5e3a; }
.bg-status[data-state="failed"] { color: #8c2941; }
.bg-rule { margin: 0 0 22px; }
.bg-rule h2, .bg-rule h3 { margin-top: 0; }
.bg-rule p, .bg-rule li { font-size: 14px; line-height: 1.7; }
.bg-rule p { margin: 8px 0; }
.bg-rule ol, .bg-rule ul { margin: 10px 0; padding-left: 23px; }
.bg-rule li + li { margin-top: 8px; }
.bg-rank-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 22px;
  padding: 4px;
  border: 1px solid var(--game-border);
  border-radius: 12px;
  background: var(--game-bg);
}
.bg-rank-tabs > :is(a, button) {
  display: flex;
  flex: 1 1 100px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--game-muted);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}
.bg-rank-tabs > [aria-pressed="true"],
.bg-rank-tabs > [aria-selected="true"],
.bg-rank-tabs > [aria-current="page"] { background: var(--game-surface); color: var(--game-text); font-weight: 700; }
.bg-ranking-period { margin:-8px 0 14px; color:var(--game-muted); font-size:14px; }
.bg-month-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
  margin: 0 0 22px;
}
.bg-month-filter label { color: var(--game-muted); font-size: 13px; }
.bg-month-filter :is(select, input) {
  display: block;
  min-width: 0;
  min-height: 44px;
  max-width: 100%;
  margin-top: 5px;
  padding: 8px 12px;
  border: 1px solid var(--game-border);
  border-radius: 10px;
  background: var(--game-surface);
  color: var(--game-text);
  font-size: 14px;
}
.bg-account-callout {
  margin: 20px 0;
  padding: 16px 18px;
  border: 1px solid var(--game-border);
  border-left: 4px solid var(--game-accent);
  border-radius: 12px;
  background: var(--game-surface);
  font-size: 14px;
  line-height: 1.6;
}
.bg-account-callout p { margin: 0; }
.bg-account-callout p + p { margin-top: 8px; }
.bg-account-callout a { text-underline-offset: 4px; }

/* Le menu conserve les couleurs, la typographie et les rangées du socle BARÆ. */
body.barae-game-menu {
  background: #faf7f0;
  color: #252b2c;
  padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
  font: 16px/1.5 system-ui, sans-serif;
}
.barae-game-menu .bg-shell { padding: 0; background: #faf7f0; color: #252b2c; font-family: system-ui, sans-serif; }
.barae-game-menu .bg-page-head { padding: 24px 24px 0; }
.barae-game-menu .bg-game-header { min-height: 92px; }
.barae-game-menu .bg-game-header img { width: 150px; height: auto; }
.barae-game-menu .bg-page-head h1,
.barae-game-menu .barae-pilot-menu-title { margin: 0 0 28px; font: 700 36px/1.15 Georgia, serif; letter-spacing: normal; }
.barae-game-menu .game-menu-list,
.barae-game-menu .barae-pilot-menu-list { overflow: hidden; border: 1px solid #e5dfd3; border-radius: 18px; background: #fff; }
.barae-game-menu .game-menu-link,
.barae-game-menu .barae-pilot-menu-link {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px;
  gap: 13px;
  align-items: center;
  min-height: 63px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  background: #fff;
  color: #252b2c;
  text-align: left;
  text-decoration: none;
  font: 600 14px/1.3 system-ui, sans-serif;
}
.barae-game-menu .game-menu-link + .game-menu-link,
.barae-game-menu .barae-pilot-menu-link + .barae-pilot-menu-link { border-top: 1px solid #e5dfd3; }
.barae-game-menu .game-menu-link > img,
.barae-game-menu .barae-pilot-menu-link > img { display: block; width: 21px; height: 21px; }
.barae-game-menu .game-menu-link > svg,
.barae-game-menu .barae-pilot-menu-link > svg { width: 16px; height: 16px; color: #687574; }
.barae-game-menu .game-menu-link:hover,
.barae-game-menu .barae-pilot-menu-link:hover { background: #faf8f3; }
/* Group headings deliberately use the actual shared pilot-nav/game-nav rules. */
.barae-game-menu .bg-page-content { padding-top: 0; }
.barae-game-menu :is(a, button):focus-visible { outline-color: #b83268; }

/* Le bandeau réserve toujours le rectangle Google de 320 × 50 pixels. */
.bg-ad-dock, .lc-ad-dock {
  position: fixed;
  right: 0;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  left: 0;
  z-index: 30;
  height: 76px;
  padding: 5px 0;
  border-top: 1px solid #e5dfd3;
  background: #faf7f0;
  color: #687574;
  font: 10px/1.4 system-ui, sans-serif;
  text-align: center;
}
.bg-ad-slot, .lc-ad-slot {
  position: relative;
  width: 320px;
  height: 50px;
  margin: 2px auto 0;
  background: #f1ece1;
}
.bg-ad-placeholder, .lc-ad-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: 9px;
  letter-spacing: .8px;
}
.bg-ad-slot[data-ad-state="filled"] .bg-ad-placeholder,
.lc-ad-slot[data-ad-state="filled"] .lc-ad-placeholder { display: none; }
.bg-ad-slot #ad-card, .lc-ad-slot #ad-card { position: relative; z-index: 1; }

@media (max-width: 380px) {
  .bg-game-header { gap: 10px; padding-inline: 16px; }
  .bg-page-head { padding-inline: 16px; }
  .bg-day-label { padding-inline: 16px; }
  .bg-page-content { padding: 20px 16px; }
  .bg-card { padding: 18px 16px; }
  .bg-calendar { gap: 4px; }
  .bg-calendar > a, .bg-calendar > span:not(.bg-weekday):not(.bg-calendar-blank) { min-height: 48px; font-size: 12px; }
  .bg-profile-stats { gap: 10px; }
  .bg-data th, .bg-data td { padding-inline: 5px; font-size: 12px; }
  .bg-data th { font-size: 10px; }
  .barae-game-menu .game-menu-link, .barae-game-menu .barae-pilot-menu-link { gap: 10px; padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-shell *, .bg-shell *::before, .bg-shell *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Bibgo identity on every game document; the common menu keeps BARÆ's theme. */
body:not(.barae-game-menu) { color-scheme:dark; --game-nav-accent:var(--game-accent); }
body:not(.barae-game-menu) .bg-game-header img { width:120px; max-width:100%; height:auto; }
body:not(.barae-game-menu) .bg-page-head h1,
body:not(.barae-game-menu) .bg-card h2,
body:not(.barae-game-menu) .bg-card h3 { font-weight:700; }
body:not(.barae-game-menu) .bg-ad-dock { background:var(--game-bg); border-color:var(--game-border); color:var(--game-muted); }
body:not(.barae-game-menu) .bg-ad-slot { background:#252030; }
body:not(.barae-game-menu) .barae-pilot-nav { background:#24202e; border-color:var(--game-border); --pilot-muted:#b4abbe; --pilot-accent:var(--game-accent); }
body:not(.barae-game-menu) .barae-pilot-status { border-color:#24202e; }
body:not(.barae-game-menu) .barae-pilot-avatar { background:#494054; color:var(--game-text); }
body:not(.barae-game-menu) .bg-calendar [data-state="won"],
body:not(.barae-game-menu) .bg-calendar [data-state="caught_up"] { color:#95dfb0; background:#163c2b; border-color:#36714e; }
body:not(.barae-game-menu) .bg-calendar [data-state="failed"] { color:#ff9eae; background:#492936; border-color:#9b5269; }
body:not(.barae-game-menu) .bg-error { color:#ff9eae; }
body:not(.barae-game-menu) .bg-message.bg-error { background:#492936; border-color:#ff9eae; }
body:not(.barae-game-menu) .bg-status[data-state="won"],
body:not(.barae-game-menu) .bg-status[data-state="caught_up"] { color:#95dfb0; }
body:not(.barae-game-menu) .bg-status[data-state="failed"] { color:#ff9eae; }

/* One daily table, with numeric medals and a portrait for every ranked player. */
.bg-ranking { table-layout:fixed; width:100%; }
.bg-ranking th:first-child { width:48px; }
.bg-ranking th:last-child { width:64px; }
.bg-ranking th:first-child, .bg-ranking td:first-child { padding-inline:0; text-align:center; }
.bg-ranking th:last-child, .bg-ranking td:last-child { text-align:right; }
.bg-rank-badge { display:inline-flex; align-items:center; justify-content:center; min-width:29px; min-height:29px; border:1px solid transparent; border-radius:50%; font-weight:700; font-variant-numeric:tabular-nums; }
.bg-rank-badge[data-rank="1"] { color:#f6d36f; background:#4c3b11; border-color:#a48232; }
.bg-rank-badge[data-rank="2"] { color:#e2e5ed; background:#343743; border-color:#9299aa; }
.bg-rank-badge[data-rank="3"] { color:#e7b08a; background:#4a3024; border-color:#a66c47; }
.bg-rank-player { display:flex; align-items:center; gap:9px; min-width:0; }
.bg-rank-name { min-width:0; overflow-wrap:anywhere; }
.bg-rank-avatar { display:grid; place-items:center; flex:0 0 32px; width:32px; height:32px; overflow:hidden; border-radius:50%; background:#44364f; color:#e8d8ff; font-size:14px; font-weight:700; }
.bg-rank-avatar img { display:block; width:32px; height:32px; max-width:none; margin:0; object-fit:cover; }
.bg-rank-avatar [hidden] { display:none !important; }
