/* Petit bac / categories game (wave 3, page petitbac). Builds on wheel.css (tokens of the .lh-app scope, buttons,
   chips, fields, switches, segmented radios, sticky action bar, sheets, full screen). Logical properties only
   (RTL by dir), dark mode through the tokens, reduced motion, a printable blank answer sheet. */

/* ---------- Layout: play column + options column (≥ 900 px) ---------- */
.lh-pb-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; margin: 0; }
.lh-pb-main { display: flex; flex-direction: column; min-width: 0; }
.lh-pb-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 900px) { .lh-pb-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 24px; } }
@media (min-width: 1100px) { .lh-pb-grid { grid-template-columns: minmax(0, 1fr) 380px; } }
html:not(.js) .lh-pb-js { display: none !important; }

/* ---------- Cards ---------- */
.lh-pb-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 12px 16px 16px; scroll-margin-block: 80px 96px;
  background: var(--lh-surface); border: 1px solid var(--lh-border); border-radius: 16px; box-shadow: var(--lh-shadow-sm);
}
.lh-pb-card:focus { outline: none; }
.lh-pb-card:focus-visible { outline: 2px solid var(--lh-focus); outline-offset: 2px; }
.lh-pb-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.lh-pb-card__h { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--lh-muted); font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.lh-pb-card__h .lh-ic { width: 18px; height: 18px; }
:lang(ar) .lh-pb-card__h { letter-spacing: 0; font-size: .875rem; }
.lh-pb-card__acts { display: inline-flex; gap: 2px; }
.lh-pb-card .lh-btn--sm { min-height: 44px; }
.lh-pb-card .lh-btn--sm.lh-btn--icon { width: 44px; min-width: 44px; }
.lh-pb-count { padding: 4px 10px; border-radius: 999px; background: var(--lh-brand-soft); color: var(--lh-brand-soft-ink); font-size: .8125rem; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lh-pb-count.is-bad { color: var(--lh-danger); background: color-mix(in srgb, var(--lh-danger) 12%, transparent); }
.lh-pb-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lh-pb-card .lh-set__row--sw { padding-block: 6px; }

/* ---------- Stage: letter reel, countdown, categories of the round ---------- */
.lh-pb-stage {
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 14px 16px; border-radius: 22px;
  border: 1px solid var(--lh-border); background: linear-gradient(180deg, var(--lh-brand-soft), var(--lh-surface) 78%);
}
.lh-pb-stage__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; inline-size: 100%; min-height: 44px; }
.lh-pb-badge { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--lh-border); background: var(--lh-surface); font-weight: 800; font-size: .875rem; font-variant-numeric: tabular-nums; }
.lh-pb-stage__top .lh-btn--icon { width: 44px; min-width: 44px; min-height: 44px; }
.lh-pb-show { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 6vw, 48px); inline-size: 100%; }

.lh-pb-reel {
  --tile: clamp(112px, 34vw, 150px);
  position: relative; flex: none; inline-size: var(--tile); block-size: var(--tile); overflow: hidden; border-radius: 22%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--lh-brand) 82%, #FFFFFF), var(--lh-brand) 60%); color: var(--lh-brand-ink);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .16), 0 12px 26px -12px color-mix(in srgb, var(--lh-brand) 80%, transparent);
}
@media (min-width: 768px) { .lh-pb-reel { --tile: 176px; } }
.lh-pb-reel::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0, 0, 0, .16), transparent 24%, transparent 76%, rgba(0, 0, 0, .16)); }
.lh-pb-strip { display: flex; flex-direction: column; will-change: transform; }
.lh-pb-l { display: grid; place-items: center; flex: none; block-size: var(--tile); font-size: calc(var(--tile) * .6); font-weight: 900; line-height: 1; }
:lang(ar) .lh-pb-l { font-size: calc(var(--tile) * .52); line-height: 1.3; }
.lh-pb-reel:not(.is-set) .lh-pb-l { opacity: .6; }
.lh-pb-reel.is-rolling .lh-pb-l { filter: blur(.7px); }
.lh-pb-reel.is-pop { animation: lh-pb-pop .38s var(--lh-ease); }
@keyframes lh-pb-pop { 0% { scale: .9; } 55% { scale: 1.06; } 100% { scale: 1; } }

.lh-pb-clockbox { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.lh-pb-clock { font-size: clamp(2.75rem, 14vw, 4.75rem); font-weight: 850; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.lh-pb-meter { display: block; inline-size: clamp(116px, 32vw, 210px); block-size: 8px; border-radius: 4px; overflow: hidden; background: color-mix(in srgb, var(--lh-text) 12%, transparent); }
.lh-pb-meter > span { display: block; block-size: 100%; background: var(--lh-success); transform-origin: left center; transition: transform .1s linear; }
[dir="rtl"] .lh-pb-meter > span { transform-origin: right center; }
.lh-pb-stage.is-low .lh-pb-clock { color: var(--lh-danger); animation: lh-pb-beat 1s ease-in-out infinite; }
.lh-pb-stage.is-low .lh-pb-meter > span { background: var(--lh-danger); }
.lh-pb-stage[data-state="done"] .lh-pb-clock, .lh-pb-stage[data-state="stop"] .lh-pb-clock { color: var(--lh-muted); }
@keyframes lh-pb-beat { 50% { scale: 1.06; } }

.lh-pb-msg { display: flex; align-items: center; justify-content: center; min-block-size: 2.9em; margin: 0; font-size: 1.0625rem; font-weight: 700; line-height: 1.35; text-align: center; text-wrap: balance; }
.lh-pb-now { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
.lh-pb-cats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lh-pb-cats li { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--lh-border); background: var(--lh-surface); font-size: .875rem; font-weight: 650; }
.lh-pb-editcats { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px; border-radius: 10px; color: var(--lh-brand-soft-ink); font-size: .875rem; font-weight: 700; text-decoration: none; }
.lh-pb-editcats:hover { background: var(--lh-surface-2); }
.lh-pb-editcats .lh-ic { width: 16px; height: 16px; }

/* ---------- Action bar: [time left on phones] [Draw / Stop!] [+15 s] ---------- */
.lh-pb .lh-bar { align-self: center; }
@media (min-width: 768px) { .lh-pb .lh-bar { max-width: 460px; } }
/* phones: the sticky bar (time left + Stop!) comes after the answer grid, so it stays in view while typing */
@media (max-width: 767.98px) {
  .lh-pb-sheet { order: 2; }
  .lh-pb .lh-bar, .lh-pb-noscript { order: 3; }
  .lh-pb .lh-bar { margin-block-start: 16px; }
}
.lh-pb-bart { display: flex; align-items: center; justify-content: center; flex: none; min-inline-size: 76px; padding: 0 12px; border-radius: 999px; background: var(--lh-surface-2); font-size: 1.125rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.lh-pb-bart.is-low { color: var(--lh-danger); }
@media (min-width: 768px) { .lh-pb-bart { display: none !important; } }
.lh-pb-plus { flex: none; height: 56px; padding: 0 16px; border-radius: 999px; font-weight: 800; }
@media (max-width: 767.98px) { .lh-pb-plus { height: 52px; border-color: transparent; background: var(--lh-surface-2); } }
@media (min-width: 768px) { .lh-pb-plus { height: 60px; } }
.lh-pb-noscript { margin-block-start: 12px; }

/* ---------- Answer grid and scores ---------- */
.lh-pb-sheet { margin-block-start: 20px; }
.lh-pb-tabs { display: flex; gap: 6px; overflow-x: auto; padding-block-end: 2px; scrollbar-width: thin; }
.lh-pb-tab {
  flex: none; max-inline-size: 12em; min-height: 44px; padding: 0 14px; border: 1px solid var(--lh-border); border-radius: 12px;
  background: var(--lh-surface); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lh-pb-tab:hover { background: var(--lh-surface-2); }
.lh-pb-tab[aria-selected="true"] { border-color: transparent; background: var(--lh-brand); color: var(--lh-brand-ink); }
.lh-pb-ed { display: flex; flex-direction: column; gap: 10px; }
.lh-pb-ed__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lh-pb-ed__t { margin: 0; font-size: 1.125rem; font-weight: 850; text-align: center; }
[dir="rtl"] .lh-pb-nav .lh-ic { transform: scaleX(-1); }
.lh-pb-alist { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.lh-pb-a { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) 52px; align-items: center; gap: 6px 10px; }
.lh-pb-a__l { font-size: .9375rem; font-weight: 650; overflow-wrap: anywhere; }
.lh-pb-a__in { min-block-size: 48px; }
.lh-pb-a__in::placeholder { color: var(--lh-muted); opacity: .7; }
.lh-pb-a__in[aria-invalid="true"] { border-color: var(--lh-danger); text-decoration: underline wavy var(--lh-danger) 1px; text-underline-offset: 4px; }
@media (max-width: 479.98px) {
  .lh-pb-a { grid-template-columns: minmax(0, 1fr) 52px; }
  .lh-pb-a__l { grid-column: 1 / -1; margin-block-end: -2px; font-size: .875rem; }
}
.lh-pb-pts {
  inline-size: 52px; block-size: 48px; border: 1px solid var(--lh-border); border-radius: 12px; background: var(--lh-surface-2);
  color: var(--lh-muted); font-size: 1.0625rem; font-weight: 850; font-variant-numeric: tabular-nums; transition: background-color .12s, color .12s;
}
.lh-pb-pts.is-5 { border-color: transparent; background: color-mix(in srgb, var(--lh-accent) 26%, var(--lh-surface)); color: var(--lh-text); }
.lh-pb-pts.is-10 { border-color: transparent; background: var(--lh-brand-soft); color: var(--lh-brand-soft-ink); }
.lh-pb-pts.is-20 { border-color: transparent; background: color-mix(in srgb, var(--lh-success) 24%, var(--lh-surface)); color: var(--lh-text); }
.lh-pb-pts.is-manual { outline: 2px dashed currentColor; outline-offset: -5px; }
.lh-pb-ed__sum { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 2px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--lh-surface-2); font-weight: 650; }
.lh-pb-ed__sum strong { font-size: 1.125rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.lh-pb-empty { margin: 0; padding: 20px 14px; border: 1px dashed var(--lh-border-strong); border-radius: 12px; color: var(--lh-muted); text-align: center; }
.lh-pb-rule { margin-block-start: 2px; }

/* grid: rows = rounds, columns = categories; scrolls inside its box (never the page) */
.lh-pb-twrap { max-block-size: 380px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--lh-border); border-radius: 12px; }
.lh-pb-twrap:focus-visible { outline: 2px solid var(--lh-focus); outline-offset: 2px; }
.lh-pb-table { inline-size: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.lh-pb-table th, .lh-pb-table td { padding: 4px 10px; border-block-end: 1px solid var(--lh-border); background: var(--lh-surface); text-align: start; vertical-align: middle; white-space: nowrap; }
.lh-pb-table thead th { position: sticky; inset-block-start: 0; z-index: 2; padding-block: 8px; background: var(--lh-surface-2); color: var(--lh-muted); font-size: .75rem; font-weight: 800; }
.lh-pb-table th:first-child { position: sticky; inset-inline-start: 0; z-index: 1; padding-inline: 4px; text-align: center; }
.lh-pb-table thead th:first-child { z-index: 3; }
.lh-pb-table tfoot th, .lh-pb-table tfoot td { position: sticky; inset-block-end: 0; z-index: 2; border-block-end: 0; background: var(--lh-surface-2); font-weight: 850; font-variant-numeric: tabular-nums; }
.lh-pb-table tfoot th:first-child { z-index: 3; font-size: .75rem; }
.lh-pb-table tr.is-sel > * { background: color-mix(in srgb, var(--lh-brand-soft) 70%, var(--lh-surface)); }
.lh-pb-rowbtn { min-inline-size: 44px; min-block-size: 44px; border: 0; border-radius: 10px; background: var(--lh-surface-2); font-size: 1.0625rem; font-weight: 900; }
.lh-pb-rowbtn[aria-current="true"] { background: var(--lh-brand); color: var(--lh-brand-ink); }
.lh-pb-tans { display: inline-block; max-inline-size: 9em; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.lh-pb-tpts { margin-inline-start: 6px; color: var(--lh-brand-soft-ink); font-size: .75rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.lh-pb-table td.is-zero { color: var(--lh-muted); }
.lh-pb-tsum { font-weight: 850; text-align: end !important; font-variant-numeric: tabular-nums; }

/* ranking */
.lh-pb-rank { display: flex; flex-direction: column; gap: 8px; padding-block-start: 8px; border-block-start: 1px solid var(--lh-border); }
.lh-pb-rank .lh-pb-card__top { flex-wrap: wrap; }
.lh-pb-rank .lh-btn { min-width: 0; white-space: normal; text-align: start; }
.lh-pb-ranklist { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lh-pb-rk { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 48px; padding-block: 4px; padding-inline: 6px 14px; border-radius: 14px; background: var(--lh-surface-2); }
.lh-pb-rk__r { display: grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 50%; background: var(--lh-surface); font-weight: 900; font-variant-numeric: tabular-nums; }
.lh-pb-rk.is-1 .lh-pb-rk__r { background: #F6C94C; color: #3A2604; }
.lh-pb-rk.is-2 .lh-pb-rk__r { background: #D5DAE3; color: #1C2233; }
.lh-pb-rk.is-3 .lh-pb-rk__r { background: #E7AE7E; color: #3A1F0A; }
.lh-pb-rk.is-1 { box-shadow: inset 0 0 0 2px #E2B032; }
.lh-pb-rk__n { overflow: hidden; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.lh-pb-rk__p { font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Options ---------- */
.lh-pb-presets, .lh-pb-catalog { display: flex; flex-wrap: wrap; gap: 12px 8px; }
.lh-pb-catalog .lh-chip, .lh-pb-presets .lh-chip { height: auto; min-height: 36px; padding-block: 6px; white-space: normal; text-align: start; }
.lh-pb-catalog .lh-chip[aria-pressed="true"]::before { content: "✓"; font-weight: 900; }
.lh-pb-presets .lh-chip[aria-pressed="true"] { border-color: var(--lh-brand); }
.lh-pb-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.lh-pb-add .lh-field { min-block-size: 48px; }
.lh-pb-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.lh-pb-key {
  position: relative; min-block-size: 44px; padding: 0; border: 1px dashed var(--lh-border-strong); border-radius: 10px;
  background: transparent; color: var(--lh-muted); font-size: 1.0625rem; font-weight: 800; text-decoration: line-through;
}
.lh-pb-key[aria-pressed="true"] { border: 1px solid transparent; background: var(--lh-brand-soft); color: var(--lh-brand-soft-ink); text-decoration: none; }
.lh-pb-key.is-drawn::after { content: ""; position: absolute; inset-block-start: 5px; inset-inline-end: 5px; inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--lh-accent); box-shadow: 0 0 0 1px var(--lh-surface); }
.lh-pb-drawn { margin: 0; color: var(--lh-muted); font-size: .875rem; overflow-wrap: anywhere; }
.lh-pb-secrow { display: flex; flex-direction: column; gap: 6px; }
.lh-pb-secrow .lh-field { max-inline-size: 160px; min-block-size: 48px; }
.lh-pb-card .lh-segr__o span { min-height: 44px; }
.lh-pb-players { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.lh-pb-players:empty { display: none; }
.lh-pb-player { display: grid; grid-template-columns: 28px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.lh-pb-player__n { display: grid; place-items: center; inline-size: 28px; block-size: 28px; border-radius: 50%; background: var(--lh-surface-2); color: var(--lh-muted); font-size: .8125rem; font-weight: 800; }
.lh-pb-player .lh-field { min-block-size: 44px; }
#lh-pb-addpl { align-self: flex-start; }
.lh-pb-invite { padding-block-start: 12px; border-block-start: 1px solid var(--lh-border); }
.lh-pb-invite .lh-btn { inline-size: 100%; white-space: normal; text-align: center; }

/* invitation dialog */
.lh-pb-qr { display: block; max-inline-size: 100%; block-size: auto; aspect-ratio: 1; margin: 4px auto; border-radius: 12px; background: #FFFFFF; }
.lh-pb-link { font-size: .8125rem; text-overflow: ellipsis; }
#lh-pb-inv .lh-pb-row .lh-btn { flex: 1 1 auto; }

/* ---------- Full screen: the stage only, as big as the room needs ---------- */
.lh-pb.lh-app--fs { overflow: auto; }
.lh-pb.lh-app--fs .lh-pb-grid { display: block; inline-size: 100%; max-inline-size: 1100px; margin: auto; }
.lh-pb.lh-app--fs .lh-pb-side, .lh-pb.lh-app--fs .lh-pb-sheet, .lh-pb.lh-app--fs .lh-pb-editcats, .lh-pb.lh-app--fs #lh-pb-fs,
.lh-pb.lh-app--fs .lh-pb-bart, .lh-pb.lh-app--fs .lh-spin__kbd { display: none !important; }
.lh-pb.lh-app--fs .lh-pb-stage { gap: 2.4vh; border: 0; background: none; }
.lh-pb.lh-app--fs .lh-pb-stage__top { justify-content: flex-start; }
.lh-pb.lh-app--fs .lh-pb-badge { font-size: clamp(1rem, 2.4vh, 1.375rem); }
.lh-pb.lh-app--fs .lh-pb-reel { --tile: min(36vh, 36vw); }
.lh-pb.lh-app--fs .lh-pb-clock { font-size: min(17vh, 15vw); }
.lh-pb.lh-app--fs .lh-pb-meter { inline-size: min(36vw, 420px); block-size: 12px; border-radius: 6px; }
.lh-pb.lh-app--fs .lh-pb-msg { font-size: clamp(1.125rem, 3.2vh, 1.875rem); }
.lh-pb.lh-app--fs .lh-pb-cats li { padding: .3em .85em; font-size: clamp(1rem, 2.8vh, 1.625rem); }
.lh-pb.lh-app--fs .lh-bar { margin-inline: auto; }

/* ---------- Print: a blank answer sheet (categories as columns) or, otherwise, no controls ---------- */
.lh-pb-print { display: none; }
@media print {
  .lh-pb-side, .lh-pb .lh-bar, .lh-pb-card__acts, .lh-pb-stage__top .lh-btn, .lh-pb-editcats, .lh-pb-ed__top .lh-btn { display: none !important; }
  html.pb-printing body * { visibility: hidden !important; }
  html.pb-printing .lh-pb-print, html.pb-printing .lh-pb-print * { visibility: visible !important; }
  html.pb-printing .lh-pb-print { display: block; position: absolute; inset-block-start: 0; inset-inline-start: 0; inline-size: 100%; page: pb-sheet; color: #000; background: #FFFFFF; font-size: 11pt; }
  /* where :has() exists, everything else is removed: the sheet is then in the normal flow (one landscape page) */
  @supports selector(:has(*)) {
    html.pb-printing *:not(:has(.lh-pb-print)):not(.lh-pb-print):not(.lh-pb-print *) { display: none !important; }
    html.pb-printing :has(.lh-pb-print) { margin: 0 !important; padding: 0 !important; border: 0 !important; min-height: 0 !important; }
    html.pb-printing .lh-pb-print { position: static; }
  }
  .lh-pb-print__t { margin: 0 0 3mm; font-size: 16pt; font-weight: 800; }
  .lh-pb-print__name { margin: 0 0 4mm; }
  .lh-pb-print__name::after { content: " ________________________________"; }
  .lh-pb-print table { inline-size: 100%; border-collapse: collapse; table-layout: fixed; }
  .lh-pb-print th, .lh-pb-print td { block-size: 11mm; padding: 1.5mm 2mm; border: 1px solid #555; font-size: 10pt; text-align: start; overflow-wrap: anywhere; }
  .lh-pb-print th:first-child, .lh-pb-print td:first-child { inline-size: 16mm; text-align: center; }
  .lh-pb-print th:last-child, .lh-pb-print td:last-child { inline-size: 18mm; }
  .lh-pb-print thead th { background: #EEEEEE; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lh-pb-print__rule { margin: 3mm 0 0; color: #333; font-size: 9pt; }
}
@page pb-sheet { size: A4 landscape; margin: 10mm; }
