/* SMRbot events page (events.html + events.js): the hero with the trophy, the filter, the grid of the 47 games and
   experiences in ten groups, the slim filter strip, the closing call, and the «طريقة اللعب» / «شاهد» dialog.
   Loads after brand.css and site.css. RTL first, holds at 360px. The motion plays even when the device asks for less
   motion: the owner wants the site to move.

   Contents
   - hero ......... .ev-hero .ev-hero-inner .ev-title .ev-stats (a.stat-chip filters by type)
   - filter ....... .ev-filter (.ev-filter-top .ev-ft-ic .ev-count .ev-tools .ev-search .ev-seg .ev-select) .ev-chips .ev-chip
   - grid ......... .ev-grid > .ggroup (group head) + .gcard (.gc-band .gc-art .gc-play | .gc-body .gc-name .gc-tags .gc-line .gc-actions | .gc-how[hidden])
   - empty ........ .ev-empty
   - strip ........ .ev-strip (fixed under the header while the grid scrolls)
   - end .......... .ev-end .ev-end-card .ev-note
   - dialog ....... dialog.gm (.gm-head .gm-tabs .gm-body .gm-how .gm-watch .gm-foot) */

/* while the dialog is open the page holds still; the scrollbar's room is kept so nothing shifts */
html.ev-lock { overflow: hidden; scrollbar-gutter: stable; }
.ev-page main { overflow-x: clip; }

/* =====================================================================================================================
   Hero
   ===================================================================================================================== */
.ev-hero {
  /* compact, as in the mockups: the hero and the filter leave the first row of games on the first screen */
  --scene-floor: var(--lt-page); --scene-maxw: 1360px; /* the gate keeps to the same wide column as the grid */
  min-height: clamp(420px, 34vw, 540px); display: flex; align-items: center;
  padding-bottom: clamp(80px, 8vw, 120px);
}
.ev-hero-inner { display: grid; gap: 16px; justify-items: start; }
.ev-hero-inner > * { max-width: 590px; }
.ev-title { font-size: clamp(38px, 4.6vw, 64px); }
.ev-hero .lead { max-width: 54ch; }
.ev-stats { margin-top: 4px; }
/* the gate and the trophy scaled to the shorter hero, so the flags stay clear of the header */
@container (min-width: 901px) {
  .ev-hero .sc-gate.is-trophy { width: clamp(330px, 40cqw, 620px); }
}
.ev-stats .stat-chip { text-decoration: none; transition: transform .5s var(--ease-out), box-shadow .5s var(--ease-out); }
.ev-stats .stat-chip:hover { transform: translateY(-4px); box-shadow: var(--sh-lg), inset 0 1px 0 rgb(255 255 255 / .9); }
.ev-stats .stat-chip:active { transform: translateY(-1px) scale(.98); }
.ev-stats .stat-chip:focus-visible { outline: 3px solid var(--yellow-500); outline-offset: 3px; }
/* up to 900px the words stand centred above the gate (between 761 and 900 the gate would sit under the stat chips) */
@media (max-width: 900px) {
  .ev-hero { min-height: 0; padding-bottom: 0; align-items: flex-start; }
  .ev-hero-inner { padding-top: 22px; justify-items: center; text-align: center; gap: 16px; }
  .ev-hero .stats-row { justify-content: center; }
  .ev-hero .scene-room { display: block; height: calc(min(92vw, 470px) * .66); }
}
@container (max-width: 900px) {
  .scene--events .sc-gate { inset-inline: 0; margin-inline: auto; width: min(92cqw, 470px); }
  .scene--events .sc-cloud:nth-child(n+2) { display: none; }
  .scene--events .sc-cloud:first-child { top: 6%; left: -4%; opacity: .45; }
}

/* =====================================================================================================================
   The filter card
   ===================================================================================================================== */
.ev-browse { position: relative; z-index: 3; padding-top: clamp(14px, 1.8vw, 26px); scroll-margin-top: var(--head-h); }
.ev-filter { --card-pad: clamp(16px, 1.6vw, 22px); display: grid; gap: 16px; border-radius: var(--r-xl); }
.ev-filter-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.ev-filter-title { display: grid; gap: 4px; }
.ev-filter .panel-title { font-size: clamp(20px, 1.8vw, 24px); gap: 12px; }
.ev-ft-ic {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; flex: none;
  background: var(--grad-teal); color: var(--yellow-500); box-shadow: 0 10px 18px -10px rgb(12 43 45 / .7), inset 0 1px 0 rgb(243 231 211 / .16);
}
.ev-ft-ic .ic { width: 21px; height: 21px; }
.ev-count { color: var(--lt-muted); font: 600 14.5px/1.4 var(--f-body); padding-inline-start: 52px; }
.ev-count b { color: var(--teal-700); font-weight: 800; font-size: 16px; display: inline-block; min-width: 1.2em; text-align: center; }

/* the tools sit beside the title on wide screens, and take a row of their own below it otherwise */
.ev-tools { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; flex: 1 1 100%; }
.ev-tools .ev-search { flex: 1 1 auto; width: auto; }
/* from 761px the count sits beside the title as a soft pill */
@media (min-width: 761px) {
  .ev-filter-title { display: flex; align-items: center; gap: 14px; flex: none; }
  .ev-count { padding: 6px 13px; border-radius: var(--r-pill); background: var(--lt-sunk); white-space: nowrap; font-size: 14px; }
}
@media (min-width: 1180px) {
  /* one row: the title with its count, then search, type and plan */
  .ev-filter-top { flex-wrap: nowrap; }
  .ev-tools { flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
  .ev-tools .ev-search { flex: 0 1 300px; min-width: 170px; }
}
/* search */
.ev-search {
  position: relative; display: flex; align-items: center; width: min(280px, 100%); height: 46px; border-radius: var(--r-pill);
  background: var(--lt-card-2); box-shadow: inset 0 0 0 1px var(--lt-line), inset 0 2px 4px rgb(21 61 64 / .05); transition: box-shadow .3s, background-color .3s;
}
.ev-search > .ic, .ev-search > [data-icon] { position: absolute; inset-inline-start: 16px; width: 19px; height: 19px; color: var(--teal-600); pointer-events: none; }
.ev-search input {
  width: 100%; height: 100%; padding-inline: 44px 16px; border: 0; background: none; outline: none; border-radius: inherit;
  font: 600 15px/1 var(--f-body); color: var(--lt-text);
}
.ev-search input::placeholder { color: rgb(79 101 103 / .8); }
.ev-search:focus-within { background: var(--lt-card); box-shadow: inset 0 0 0 2px var(--teal-500), 0 0 0 4px rgb(63 135 138 / .14); }
.ev-search input::-webkit-search-cancel-button { cursor: pointer; }
/* type: a segmented control with a sliding pill */
.ev-seg {
  position: relative; isolation: isolate; display: inline-flex; height: 46px; padding: 4px; border-radius: var(--r-pill);
  background: var(--lt-sunk); box-shadow: inset 0 1px 3px rgb(21 61 64 / .08);
}
.ev-seg button {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; border: 0; border-radius: var(--r-pill);
  background: none; color: var(--lt-text-2); font: 700 14.5px/1 var(--f-body); cursor: pointer; white-space: nowrap; transition: color .35s;
}
.ev-seg button .num { font-size: 12.5px; opacity: .75; }
.ev-seg button[aria-checked="true"] { color: var(--cream-100); }
.ev-seg button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.ev-seg-ink {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: var(--w, 60px); border-radius: var(--r-pill);
  background: var(--grad-teal); box-shadow: 0 8px 18px -10px rgb(12 43 45 / .8), inset 0 1px 0 rgb(243 231 211 / .14);
  transform: translateX(var(--x, 0px)); transition: transform .55s var(--ease-out), width .55s var(--ease-out);
}
/* plan: a styled select */
.ev-select { position: relative; display: inline-flex; align-items: center; height: 46px; }
.ev-select select {
  appearance: none; -webkit-appearance: none; height: 100%; padding-inline: 42px 40px; border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: var(--lt-card-2); box-shadow: inset 0 0 0 1px var(--lt-line); color: var(--lt-text); font: 700 14.5px/1 var(--f-body);
  transition: box-shadow .3s;
}
.ev-select select:hover { box-shadow: inset 0 0 0 1px var(--lt-line-2); }
.ev-select select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ev-select > [data-icon]:first-child { position: absolute; inset-inline-start: 15px; color: var(--yellow-700); pointer-events: none; }
.ev-select > [data-icon]:first-child .ic { width: 18px; height: 18px; }
.ev-select-chev { position: absolute; inset-inline-end: 14px; color: var(--teal-600); pointer-events: none; }
.ev-select-chev .ic { width: 17px; height: 17px; }

/* the group chips: a tile above the word, a count in the corner. Every tile starts at the top and the word sits in a
   two-line slot, so the icons line up whether the word takes one line or two */
.ev-chips { gap: 10px; padding-top: 8px; }
.ev-chip { position: relative; justify-content: flex-start; min-width: 104px; min-height: 0; padding: 13px 8px 10px; gap: 7px; white-space: normal; text-align: center; border-radius: 20px; }
.ev-chip-art { display: block; line-height: 0; }
.ev-chip-art .tile { width: 34px; filter: drop-shadow(0 6px 8px rgb(12 43 45 / .2)); }
.ev-chip-l { display: grid; place-items: center; min-height: calc(2 * 1.3em); font: 700 13.5px/1.3 var(--f-body); text-wrap: balance; }
.ev-chip .chip-n { position: absolute; top: 7px; inset-inline-end: 7px; min-width: 22px; height: 20px; padding: 0 6px; font-size: 11.5px; }
.ev-chip:hover .ev-chip-art .tile .tile-art { transform: translateY(-2px) scale(1.08) rotate(-4deg); }
.ev-chip[aria-pressed="true"] { transform: translateY(-2px); }
.ev-chip[aria-pressed="true"] .chip-n { background: var(--yellow-500); color: var(--teal-900); }
.ev-chip.is-zero:not([aria-pressed="true"]) { opacity: .5; }
/* from 761px every tile shows: one row of eleven on wide screens, three full rows of four below 1180px («الكل» takes two) */
@media (min-width: 761px) {
  .ev-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; padding: 6px 0 2px; margin: 0; mask-image: none; }
  .ev-chip { min-width: 0; }
}
@media (min-width: 1180px) {
  .ev-chips { grid-template-columns: repeat(11, minmax(0, 1fr)); }
}
/* three rows: each tile lies flat, the drawing beside the word and the count at its end */
@media (min-width: 761px) and (max-width: 1179px) {
  .ev-chips { row-gap: 8px; }
  .ev-chip[data-group="all"] { grid-column: span 2; }
  .ev-chip { flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; min-height: 54px; padding: 8px 12px; text-align: start; border-radius: 18px; }
  .ev-chip-art .tile { width: 32px; }
  .ev-chip-l { flex: 1; display: block; min-height: 0; }
  .ev-chip .chip-n { position: static; flex: none; }
}
/* phones: the tiles slide sideways, edge to edge inside the card (the rail around them is added by events.js) */
@media (max-width: 760px) {
  .ev-filter > .ev-rail, .ev-filter > .ev-chips { margin-inline: calc(var(--card-pad) * -1); }
  .ev-chips { --rail-fade: var(--card-pad); padding-inline: var(--card-pad); scroll-padding-inline: var(--card-pad); }
  .ev-filter > .ev-chips { mask-image: linear-gradient(90deg, transparent, #000 var(--card-pad), #000 calc(100% - var(--card-pad)), transparent); }
}
@media (max-width: 760px) {
  .ev-tools { flex-wrap: wrap; }
  .ev-tools .ev-search { width: 100%; flex: 1 1 100%; }
  .ev-seg { flex: 1 1 auto; }
  .ev-seg button { flex: 1; justify-content: center; padding: 0 10px; }
  .ev-select { flex: 1 1 160px; }
  .ev-select select { width: 100%; }
  .ev-chip { min-width: 92px; min-height: 90px; }
}
@media (max-width: 420px) {
  .ev-count { padding-inline-start: 0; }
  .ev-seg button { font-size: 14px; padding: 0 8px; }
  .ev-select { flex-basis: 100%; }
}

/* =====================================================================================================================
   The grid: group heads across the row, game cards under them
   ===================================================================================================================== */
/* A wrapping row: --cols cards a row; a row that is not full (the end of a group, or of a search) shares the whole width
   between its cards, and events.js lays those wider cards on their side (.gc-wide). One card alone on a five-column row
   stops at half the row and stands in the middle (--cap). */
.ev-grid {
  --cols: 5; --gap: 18px; --cap: calc((100% - var(--gap)) / 2);
  display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); margin-top: clamp(18px, 2.2vw, 30px);
}
.ev-grid > .gcard { flex: 1 1 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols) - .5px); max-width: var(--cap); }
@media (max-width: 1279px) { .ev-grid { --cols: 3; --cap: 100%; } }
@media (max-width: 859px) { .ev-grid { --cols: 2; --gap: 14px; } }
@media (max-width: 559px) { .ev-grid { --cols: 1; --gap: 12px; } }
.ev-grid > [hidden] { display: none !important; }
.ev-grid.is-flat > .ggroup { display: none; }
/* before events.js shows them (a fail-safe shows everything after 3s if it never runs) */
.ev-js .ev-grid > :not(.shown) { opacity: 0; }
html.ev-js:not(.ev-ready) .ev-grid > * { animation: ev-failsafe .01s 3s forwards; }
@keyframes ev-failsafe { to { opacity: 1; } }

/* a group head */
.ggroup {
  flex: 0 0 100%; min-width: 0; display: grid; grid-template-columns: auto minmax(0, auto) minmax(20px, 1fr) auto; align-items: center; gap: 4px 18px;
  padding: clamp(18px, 2.2vw, 30px) 2px 0; scroll-margin-top: calc(var(--head-h) + 84px);
}
/* the first group shown (events.js marks it) sits close under the filter */
.ggroup.is-first { padding-top: 2px; }
.gg-tile { line-height: 0; }
.gg-tile .tile { width: clamp(48px, 4vw, 56px); }
/* the number rides beside the name as a small badge, the line under them */
.gg-text { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; min-width: 0; }
.gg-no {
  order: 2; display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: var(--r-pill);
  background: rgb(255 122 86 / .1); box-shadow: inset 0 0 0 1px rgb(255 122 86 / .22); font: 700 12.5px/1.4 var(--f-body); color: var(--coral-text);
}
.gg-no .num { font-weight: 800; }
.gg-name { order: 1; font: 800 clamp(21px, 2vw, 27px)/1.3 var(--f-display); color: var(--lt-text); }
.gg-desc { order: 3; flex: 1 0 100%; color: var(--lt-muted); font-size: 15px; line-height: 1.6; }
.gg-rule { height: 2px; border-radius: 2px; align-self: center; background: linear-gradient(270deg, rgb(255 122 86 / .55), rgb(255 203 87 / .45) 35%, rgb(21 61 64 / .08) 70%, transparent); }
[dir="ltr"] .gg-rule { transform: scaleX(-1); }
/* as a group head comes into view its tile pops in and its line draws out from the title */
.gg-rule { transform-origin: 100% 50%; }
.ggroup.shown .gg-rule { animation: gg-rule 1.5s var(--ease-out) .2s both; }
.ggroup.shown .gg-tile .tile { animation: gg-pop .9s var(--ease-spring) .05s both; }
@keyframes gg-rule { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
@keyframes gg-pop { from { transform: scale(.55) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.gg-count { display: inline-flex; align-items: baseline; gap: 5px; padding: 7px 15px; border-radius: var(--r-pill); background: var(--lt-card); box-shadow: var(--sh-xs), inset 0 0 0 1px var(--lt-line); color: var(--lt-text-2); font: 700 13.5px/1.2 var(--f-body); white-space: nowrap; }
.gg-count b { font-size: 15px; color: var(--teal-700); }
@media (max-width: 640px) {
  .ggroup { grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 14px; }
  .gg-rule { display: none; }
  .gg-desc { font-size: 14px; }
  .gg-count { padding: 5px 11px; font-size: 12.5px; }
}

/* a game card: a coloured band (the game's tile colour, its drawing, sparkles, cream waves at its foot) over the text */
.gcard {
  --gc-a: #3A8084; --gc-b: #174245;
  position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; isolation: isolate;
  border-radius: 22px; background: var(--lt-card); border: 1px solid var(--lt-line);
  box-shadow: var(--sh-md), inset 0 1px 0 rgb(255 255 255 / .9);
  transition: transform .55s var(--ease-out), box-shadow .55s var(--ease-out), border-color .3s;
  scroll-margin-top: calc(var(--head-h) + 84px);
}
.gcard:hover { transform: translateY(-6px); box-shadow: var(--sh-lg), inset 0 1px 0 rgb(255 255 255 / .9); border-color: var(--lt-line-2); }
.gc--teal { --gc-a: #3A8084; --gc-b: #174245; }
.gc--deep { --gc-a: #2A666A; --gc-b: #0C2B2D; }
.gc--ember { --gc-a: #EC6E47; --gc-b: #A3371C; }
.gc--coral { --gc-a: #FFA27D; --gc-b: #EF6440; }
.gc--gold { --gc-a: #FFE6A0; --gc-b: #F5AE45; }
.gc--sun { --gc-a: #FFCB66; --gc-b: #FF7E58; }
.gc--cream { --gc-a: #FFFCF5; --gc-b: #EBD8B8; }

.gc-band {
  /* no clipping here: the card clips, so the waves always cover the band's edges (no hairline at fractional widths) */
  position: relative; isolation: isolate; overflow: visible; display: block; width: calc(100% + 2px); height: clamp(100px, 7.6vw, 110px); flex: none;
  margin: -1px -1px 0; /* reaches under the card's border, so the card's clip trims band and waves on the same line */
  padding: 0; border: 0; border-radius: 0; cursor: pointer; color: inherit; font: inherit; text-align: inherit;
  background:
    radial-gradient(closest-side circle at 50% 62%, rgb(255 255 255 / .26), transparent),
    radial-gradient(90% 75% at 85% -5%, rgb(255 255 255 / .30), transparent 62%),
    linear-gradient(160deg, var(--gc-a), var(--gc-b));
}
/* two cream waves at the foot of the band; they slide apart when the card is hovered */
.gc-band::before, .gc-band::after {
  content: ""; position: absolute; left: -12%; right: -12%; bottom: -1px; z-index: 2; pointer-events: none;
  background: no-repeat bottom / 100% 100%; transition: transform 1.1s var(--ease-out);
}
.gc-band::before { height: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 60' preserveAspectRatio='none'%3E%3Cpath d='M0 26C80 6 170 8 250 24S410 52 490 30S570 12 600 20V60H0Z' fill='%23fff' fill-opacity='.24'/%3E%3C/svg%3E"); }
.gc-band::after { height: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 60' preserveAspectRatio='none'%3E%3Cpath d='M0 40C90 22 180 24 270 38S440 58 530 40S585 30 600 34V60H0Z' fill='%23FFFBF4'/%3E%3C/svg%3E"); }
.gcard:hover .gc-band::before { transform: translateX(5%); }
.gcard:hover .gc-band::after { transform: translateX(-4%); }
.gc-art { position: absolute; z-index: 1; left: 50%; bottom: 12px; width: 84px; translate: -50% 0; line-height: 0; }
.gc-art .tile { width: 100%; }
.gc-art .tile .tile-art { transition: transform .7s var(--ease-spring); }
.gcard:hover .gc-art .tile .tile-art, .gc-band:focus-visible .gc-art .tile .tile-art { transform: translateY(-5px) scale(1.07) rotate(-4deg); }
.gc-band .sc-spark { z-index: 1; }
.gcard:not(:hover) .gc-band .sc-spark { animation-play-state: paused; }
/* «معاينة البطاقة» on the band: it opens the dialog on the preview of the card the bot sends */
.gc-play {
  position: absolute; z-index: 3; top: 12px; inset-inline-start: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 13px; border-radius: var(--r-pill); font: 700 13px/1 var(--f-body);
  background: rgb(255 251 244 / .9); color: var(--teal-800); box-shadow: 0 6px 16px -8px rgb(12 43 45 / .55), inset 0 1px 0 #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .45s var(--ease-spring), background-color .3s, color .3s, box-shadow .45s var(--ease-out);
}
.gc-play .ic { width: 15px; height: 15px; color: var(--coral-600); transition: transform .45s var(--ease-spring), color .3s; }
.gc-band:hover .gc-play, .gc-band:focus-visible .gc-play { transform: scale(1.06); background: var(--coral-500); color: #0A2426; box-shadow: var(--sh-coral); }
.gc-band:hover .gc-play .ic, .gc-band:focus-visible .gc-play .ic { color: #0A2426; transform: scale(1.15); }
/* keyboard focus on the band: a teal ring around the whole card (an inset ring vanished on the teal bands) */
.gc-band:focus-visible { outline: none; }
.gcard:has(.gc-band:focus-visible) { outline: 3px solid var(--teal-600); outline-offset: 3px; }
@supports not selector(:has(*)) { .gc-band:focus-visible { outline: 3px solid var(--yellow-500); outline-offset: -5px; } }

.gc-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; padding: 2px 18px 16px; }
.gc-name { font: 800 19.5px/1.35 var(--f-display); color: var(--lt-text); text-wrap: balance; }
.gc-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.gc-tags .pill { padding: 4px 10px; }
.gc-kind { background: transparent; color: var(--lt-text-2); box-shadow: inset 0 0 0 1px var(--lt-line-2); }
.gc-kind .ic { color: var(--teal-600); }
.gc-players { display: inline-flex; align-items: center; gap: 5px; font: 600 12.5px/1.3 var(--f-body); color: var(--lt-muted); }
.gc-players .ic { width: 14px; height: 14px; color: var(--teal-500); }
/* two lines on the card; the whole line opens in «طريقة اللعب» */
.gc-line { font-size: 14.5px; line-height: 1.75; color: var(--lt-muted); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.gc-actions { margin-top: auto; padding-top: 2px; display: flex; }
.gc-actions .btn { flex: 1; }
/* the deep-linked card glows for a moment */
.gcard.is-target { animation: gc-target 2.4s var(--ease-out) 1; }
@keyframes gc-target {
  0%, 100% { box-shadow: var(--sh-md), 0 0 0 0 rgb(255 122 86 / 0); }
  18%, 55% { box-shadow: var(--sh-lg), 0 0 0 4px rgb(255 122 86 / .75); }
}

/* a wide card (it fills the end of a row that is not full): it lies on its side, the band at the end, like on phones */
.gcard.gc-wide { flex-direction: row; }
.gc-wide .gc-body { order: 1; padding: 16px 20px; padding-inline-end: 14px; justify-content: center; }
.gc-wide .gc-band { order: 2; width: clamp(150px, 34%, 240px); height: auto; min-height: calc(100% + 2px); margin: -1px; margin-inline-start: 0; }
.gc-wide .gc-band::before, .gc-wide .gc-band::after { left: auto; right: -1px; top: -12%; bottom: -12%; height: auto; background-size: 100% 100%; }
.gc-wide .gc-band::before { width: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 600' preserveAspectRatio='none'%3E%3Cpath d='M34 0C54 80 52 170 36 250S8 410 30 490S48 570 40 600H60V0Z' fill='%23fff' fill-opacity='.24'/%3E%3C/svg%3E"); }
.gc-wide .gc-band::after { width: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 600' preserveAspectRatio='none'%3E%3Cpath d='M20 0C38 90 36 180 22 270S2 440 20 530S34 585 26 600H60V0Z' fill='%23FFFBF4'/%3E%3C/svg%3E"); }
.gcard.gc-wide:hover .gc-band::before { transform: translateY(5%); }
.gcard.gc-wide:hover .gc-band::after { transform: translateY(-4%); }
.gc-wide .gc-art { left: calc(50% - 10px); top: 50%; bottom: auto; width: 96px; translate: -50% -56%; }
.gc-wide .gc-play { inset-inline-start: auto; inset-inline-end: 14px; }
.gc-wide .gc-actions .btn { flex: 0 1 auto; min-width: 190px; }

/* phones: the card lies on its side, the band at the end */
@media (max-width: 559px) {
  .gcard { flex-direction: row; }
  .gc-body { order: 1; padding: 14px 16px; padding-inline-end: 12px; gap: 8px; }
  .gc-band { order: 2; width: 118px; height: auto; min-height: calc(100% + 2px); margin: -1px; margin-inline-start: 0; }
  .gc-band::before, .gc-band::after { left: auto; right: -1px; top: -12%; bottom: -12%; height: auto; background-size: 100% 100%; }
  .gc-band::before { width: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 600' preserveAspectRatio='none'%3E%3Cpath d='M34 0C54 80 52 170 36 250S8 410 30 490S48 570 40 600H60V0Z' fill='%23fff' fill-opacity='.24'/%3E%3C/svg%3E"); }
  .gc-band::after { width: 22px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 600' preserveAspectRatio='none'%3E%3Cpath d='M20 0C38 90 36 180 22 270S2 440 20 530S34 585 26 600H60V0Z' fill='%23FFFBF4'/%3E%3C/svg%3E"); }
  .gcard:hover .gc-band::before { transform: translateY(5%); }
  .gcard:hover .gc-band::after { transform: translateY(-4%); }
  .gc-art { left: calc(50% - 8px); top: 50%; bottom: auto; width: 82px; translate: -50% -58%; }
  .gc-play { top: auto; bottom: 10px; inset-inline-start: auto; left: calc(50% - 8px); translate: -50% 0; padding: 5px 10px; font-size: 12px; }
  .gc-name { font-size: 18.5px; }
  .gc-line { font-size: 14px; line-height: 1.7; }
  .gc-actions .btn { min-height: 40px; }
}
@media (max-width: 380px) {
  .gc-band { width: 104px; }
  .gc-art { width: 74px; }
  .gc-body { padding-inline-start: 14px; }
}
[dir="ltr"] .gcard { direction: ltr; }
/* the band is narrow on phones: «معاينة البطاقة» says «معاينة» there */
.gc-play-s { display: none; } /* (in English, "Card preview" says "Preview" there) */
@media (max-width: 559px) { .gc-play-x { display: none; } .gc-play-s { display: inline; } }
/* in English the band on its side sits at the right: its waves face the text on its left, the drawing leans away from them */
[dir="ltr"] .gc-wide .gc-band::before, [dir="ltr"] .gc-wide .gc-band::after { right: auto; left: -1px; scale: -1 1; }
[dir="ltr"] .gc-wide .gc-art { left: calc(50% + 10px); }
@media (max-width: 559px) {
  [dir="ltr"] .gc-band::before, [dir="ltr"] .gc-band::after { right: auto; left: -1px; scale: -1 1; }
  [dir="ltr"] .gc-art, [dir="ltr"] .gc-play { left: calc(50% + 8px); }
}

/* nothing matches */
.ev-empty { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin-top: 26px; padding: 22px 24px; }
.ev-empty[hidden] { display: none; }
.ev-empty > div { flex: 1 1 240px; display: grid; gap: 4px; }
.ev-empty .tile { width: 58px; }

/* =====================================================================================================================
   The strip: the group chips follow the reader down the grid, under the header
   ===================================================================================================================== */
.ev-strip { position: fixed; z-index: 45; top: calc(var(--head-h) + env(safe-area-inset-top)); inset-inline: 0; height: 96px; overflow: hidden; pointer-events: none; }
.ev-strip-in {
  display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 14px; margin-top: 0;
  border-radius: 0 0 22px 22px; background: rgb(255 251 244 / .86); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 18px 32px -20px rgb(12 43 45 / .45), inset 0 0 0 1px var(--lt-line);
  transform: translateY(-110%); opacity: 0; transition: transform .6s var(--ease-out), opacity .4s var(--ease-soft);
}
.ev-strip.on { pointer-events: none; }
.ev-strip.on .ev-strip-in { transform: none; opacity: 1; pointer-events: auto; }
/* while the strip shows, a card brought into view by the keyboard stops below it, not under it */
:root.ev-strip-on { scroll-padding-top: calc(var(--head-h) + 84px); }
.ev-strip-in > .ev-rail { flex: 1; min-width: 0; }
.ev-strip-chips { flex: 1; min-width: 0; gap: 6px; padding: 4px 2px; margin: 0; mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent); }
.ev-strip-chips .chip { min-height: 40px; padding: 7px 13px; font-size: 14px; gap: 7px; }
.ev-strip-chips .chip .ic { width: 17px; height: 17px; }
.ev-strip-chips .chip-n { height: 20px; min-width: 22px; font-size: 11.5px; }
.ev-strip-more { flex: none; color: var(--teal-700); gap: 7px; padding-inline: 14px; }
.ev-strip-more .ic { width: 19px; height: 19px; }
.ev-strip-n { font-weight: 800; }
@media (max-width: 640px) {
  .ev-strip-in { height: 58px; padding: 0 8px; border-radius: 0 0 18px 18px; width: 100%; }
  .ev-strip-chips .chip { min-height: 38px; padding: 6px 11px; font-size: 13.5px; }
}

/* =====================================================================================================================
   The rail (events.js wraps each sliding row of chips in it): the row fades only on the side that has more, and with a
   mouse two round arrows slide it and the wheel moves it sideways
   ===================================================================================================================== */
.ev-rail { position: relative; min-width: 0; }
.ev-rail > .chips-scroll {
  --fl: 0px; --fr: 0px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fl), #000 calc(100% - var(--fr)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--fl), #000 calc(100% - var(--fr)), transparent);
}
.ev-rail.more-left > .chips-scroll { --fl: var(--rail-fade, 64px); }
.ev-rail.more-right > .chips-scroll { --fr: var(--rail-fade, 64px); }
.ev-rail-btn {
  position: absolute; z-index: 2; top: 50%; display: none; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: var(--lt-card); color: var(--teal-700); cursor: pointer; box-shadow: 0 8px 18px -8px rgb(12 43 45 / .45), inset 0 0 0 1px var(--lt-line);
  opacity: 0; pointer-events: none; transform: translateY(-50%) scale(.7);
  transition: opacity .35s var(--ease-soft), transform .5s var(--ease-spring), background-color .3s, color .3s;
}
.ev-rail-btn.is-left { left: 0; }
.ev-rail-btn.is-right { right: 0; }
.ev-rail-btn .ic { width: 18px; height: 18px; transition: transform .45s var(--ease-spring); }
.ev-rail-btn:hover { background: var(--teal-700); color: var(--cream-100); }
.ev-rail-btn.is-left:hover .ic { transform: translateX(-2px); }
.ev-rail-btn.is-right:hover .ic { transform: translateX(2px); }
@media (hover: hover) and (pointer: fine) {
  .ev-rail-btn { display: grid; }
  .ev-rail.more-left > .is-left, .ev-rail.more-right > .is-right { opacity: 1; pointer-events: auto; transform: translateY(-50%); }
  .ev-rail.more-left > .is-left:active, .ev-rail.more-right > .is-right:active { transform: translateY(-50%) scale(.9); }
  .ev-rail > .chips-scroll { scroll-snap-type: none; }
}

/* =====================================================================================================================
   The closing call
   ===================================================================================================================== */
.ev-end { padding-top: clamp(56px, 7vw, 96px); }
.ev-end-card {
  position: relative; isolation: isolate; overflow: hidden; border-radius: var(--r-2xl); min-height: clamp(300px, 26vw, 360px);
  display: grid; align-content: center; padding: clamp(28px, 4vw, 52px) clamp(22px, 4vw, 56px) clamp(60px, 6vw, 84px);
  color: var(--dk-text); color-scheme: dark; --focus: var(--yellow-500); box-shadow: var(--sh-xl); --scene-floor: var(--lt-page);
}
.ev-end-card .sc-cloud:nth-child(1) { --x: 6% !important; --y: 14% !important; }
.ev-end-card .sc-cloud:nth-child(2) { --x: 24% !important; --y: 40% !important; }
.ev-end-copy { position: relative; z-index: 2; display: grid; gap: 14px; justify-items: start; max-width: min(560px, 54%); }
.ev-end-title { font: 800 clamp(26px, 3.2vw, 40px)/1.3 var(--f-display); }
.ev-end-copy p { color: var(--dk-muted); font-size: clamp(16px, 1.35vw, 18px); line-height: 1.85; }
.ev-end-copy .btn-row { margin-top: 6px; }
.ev-note { display: flex; align-items: flex-start; justify-content: center; gap: 8px; margin-top: 18px; color: var(--lt-muted); font-size: 14.5px; text-align: center; }
.ev-note .ic { width: 18px; height: 18px; margin-top: 4px; color: var(--teal-500); }
/* narrower: the gate would stand behind the words, so the card keeps only its sky and hills */
@media (max-width: 900px) {
  .ev-end-card .sc-gate { display: none; }
  .ev-end-copy { max-width: 620px; }
}
@media (max-width: 760px) {
  .ev-end-card { padding-bottom: 92px; }
}
@media (max-width: 420px) { .ev-end-copy .btn-row .btn { flex: 1 1 100%; } }

/* =====================================================================================================================
   The dialog: «طريقة اللعب» and «شاهد البطاقة» for one game, with the next and previous games at its foot
   ===================================================================================================================== */
/* The top edge stays put (only the foot moves, and events.js glides the height) when the tab or the game changes.
   --gm-top centres a dialog of about 820px; --gm-img-h is the most the card's picture may take. */
dialog.gm {
  --gm-top: clamp(16px, calc((100vh - 820px) / 2), 10vh);
  --gm-img-h: clamp(190px, calc(100vh - var(--gm-top) - 410px), 500px);
  width: min(760px, calc(100vw - 32px)); margin: var(--gm-top) auto auto; max-height: calc(100vh - var(--gm-top) - 16px);
}
.gm-head { gap: 14px; padding: 16px 20px 30px; }
/* three opaque hills at the foot of the head, like the footer's: coral, yellow in front, and the cream of the body */
.gm-head::after {
  content: ""; position: absolute; inset: auto -2% -1px; height: 30px; z-index: -1; pointer-events: none;
  background: no-repeat bottom / 100% 100% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 60' preserveAspectRatio='none'%3E%3Cpath d='M0 20C90 2 190 6 290 20S470 44 600 14V60H0Z' fill='%23FF7A56'/%3E%3Cpath d='M0 34C110 16 220 22 320 34S500 50 600 28V60H0Z' fill='%23FFCB57'/%3E%3Cpath d='M0 46C120 32 240 36 340 46S520 58 600 40V60H0Z' fill='%23FFFBF4'/%3E%3C/svg%3E");
  animation: gm-hills 14s ease-in-out infinite alternate;
}
@keyframes gm-hills { from { transform: translateX(-1%); } to { transform: translateX(1%); } }
.gm-tile { line-height: 0; flex: none; }
.gm-tile .tile { width: 56px; }
.gm-titles { display: grid; gap: 0; min-width: 0; }
.gm-group { font: 700 13px/1.4 var(--f-body); color: var(--yellow-300); }
.gm-head h2 { font: 800 clamp(20px, 2.4vw, 24px)/1.35 var(--f-display); }
.gm-head .modal-close { flex: none; }

.gm-tabs { position: relative; isolation: isolate; flex: none; display: flex; gap: 0; margin: 8px 20px 0; padding: 4px; border-radius: var(--r-pill); background: var(--lt-sunk); box-shadow: inset 0 1px 3px rgb(21 61 64 / .08); }
.gm-tabs [role="tab"] {
  position: relative; z-index: 1; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 0; border-radius: var(--r-pill);
  background: none; color: var(--lt-text-2); font: 700 15px/1 var(--f-body); cursor: pointer; transition: color .35s;
}
.gm-tabs [role="tab"] .ic { width: 18px; height: 18px; }
.gm-tabs [role="tab"][aria-selected="true"] { color: var(--cream-100); }
.gm-tabs [role="tab"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.gm-tab-ink {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: var(--w, 50%); border-radius: var(--r-pill);
  background: var(--grad-teal); box-shadow: 0 8px 18px -10px rgb(12 43 45 / .8), inset 0 1px 0 rgb(243 231 211 / .14);
  transform: translateX(var(--x, 0px)); transition: transform .55s var(--ease-out), width .55s var(--ease-out);
}
.gm-body { padding: 16px 20px 20px; display: grid; gap: 16px; align-content: start; flex: 1; min-height: 0; }
.gm-tags { list-style: none; margin: 0; padding: 0; }
.gm-panel:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 12px; }
.gm-panel[hidden] { display: none; }
.gm-lead { font: 600 16.5px/1.8 var(--f-body); color: var(--lt-text-2); margin-bottom: 14px; }
.gm-start {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; margin-bottom: 20px; border-radius: 16px;
  background: linear-gradient(180deg, var(--yellow-50), #FFF6E0); box-shadow: inset 0 0 0 1px rgb(242 174 58 / .32);
  color: var(--lt-text-2); font-size: 15.5px; line-height: 1.85;
}
.gm-start > .ic { flex: none; width: 30px; height: 30px; padding: 6px; margin-top: 1px; border-radius: 10px; background: var(--grad-gold); color: var(--teal-900); box-shadow: var(--sh-gold); }
.gm-start b { color: var(--coral-text); }
.gm-how code, .gm-start code {
  font: 700 13.5px/1.4 var(--f-latin); background: var(--teal-100); color: var(--teal-800); padding: 2px 9px; border-radius: 8px; white-space: nowrap;
}
/* the steps as a numbered path */
.gm-how .steps-list { list-style: none; margin: 0; padding: 0; display: grid; counter-reset: st; }
.gm-how .steps-list li { position: relative; counter-increment: st; padding: 4px 0 18px; padding-inline-start: 50px; font-size: 16px; line-height: 1.85; color: var(--lt-text); }
.gm-how .steps-list li:last-child { padding-bottom: 2px; }
.gm-how .steps-list li::before {
  content: counter(st); position: absolute; top: 2px; inset-inline-start: 0; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font: 800 15px/1 var(--f-latin); color: var(--cream-100);
  background: var(--grad-teal); box-shadow: 0 8px 16px -8px rgb(12 43 45 / .7), inset 0 1px 0 rgb(243 231 211 / .2);
}
.gm-how .steps-list li:nth-child(even)::before { background: var(--grad-coral); color: #0A2426; box-shadow: var(--sh-coral); }
.gm-how .steps-list li::after { content: ""; position: absolute; inset-inline-start: 16px; top: 40px; bottom: 2px; width: 2px; border-radius: 2px; background: linear-gradient(180deg, var(--teal-200), rgb(199 221 218 / .2)); }
.gm-how .steps-list li:last-child::after { display: none; }

/* the card as the bot sends it */
.gm-fig { display: grid; gap: 12px; }
/* the frame takes the picture's own shape and size (events.js sets --ar from the GIF's width and height), so there are
   no cream gutters beside it and the room is kept before the GIF arrives */
.gm-frame {
  --ar: 1000 / 680;
  position: relative; overflow: hidden; width: min(100%, calc(var(--gm-img-h) * var(--ar))); aspect-ratio: var(--ar); margin-inline: auto;
  border-radius: 16px; background: var(--cream-300); line-height: 0; box-shadow: 0 22px 44px -24px rgb(12 43 45 / .6);
}
.gm-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .5s var(--ease-out); }
.gm-fig.loading .gm-frame img { opacity: 0; }
.gm-fig.loading .gm-frame::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / .55) 50%, transparent 70%) var(--cream-300);
  background-size: 220% 100%; animation: gm-shimmer 1.3s linear infinite;
}
@keyframes gm-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
/* «معاينة»: says plainly that this is a picture of the card, and where the bot can be tried on the site */
.gm-fig figcaption { color: var(--lt-muted); font-size: 14.5px; line-height: 1.7; text-align: center; text-wrap: pretty; }
.gm-fig figcaption .ic { display: inline-block; width: 16px; height: 16px; margin-inline-end: 6px; vertical-align: -3px; color: var(--yellow-700); }
.gm-fig figcaption a { color: var(--teal-700); font-weight: 700; text-decoration: underline; text-decoration-color: rgb(46 110 114 / .35); text-underline-offset: 3px; white-space: nowrap; }
.gm-fig figcaption a:hover { color: var(--coral-text); text-decoration-color: currentColor; }

.gm-foot { flex: none; display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--lt-line); background: var(--lt-card-2); }
.gm-foot[hidden] { display: none; }
.gm-step {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 48%; padding: 8px 12px; border: 0; border-radius: 16px;
  background: none; color: var(--lt-text); cursor: pointer; text-align: start; transition: background-color .3s, transform .4s var(--ease-out);
}
.gm-step > span { display: grid; min-width: 0; }
.gm-step small { font: 600 12.5px/1.3 var(--f-body); color: var(--lt-muted); }
.gm-step b { font: 800 15px/1.4 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gm-step .ic { flex: none; width: 34px; height: 34px; padding: 8px; border-radius: 50%; background: var(--teal-100); color: var(--teal-700); transition: background-color .3s, color .3s, transform .45s var(--ease-spring); }
.gm-step:hover { background: var(--lt-sunk); }
.gm-prev:hover .ic { transform: translateX(3px); background: var(--teal-700); color: var(--cream-100); }
.gm-next:hover .ic { transform: translateX(-3px); background: var(--teal-700); color: var(--cream-100); }
.gm-next { text-align: end; }
/* in English the foot mirrors: the arrows turn with it */
[dir="ltr"] .gm-step .ic { scale: -1 1; }
.gm-step:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 600px) {
  /* the sheet keeps one height, so its top edge never jumps as the tab or the game changes */
  dialog.gm { width: 100vw; max-width: 100vw; margin: auto 0 0; height: min(86vh, 760px); height: min(86dvh, 760px); max-height: 92vh; }
  .gm-head { padding: 14px 16px 28px; }
  .gm-tile .tile { width: 46px; }
  .gm-tabs { margin: 12px 14px 0; }
  .gm-body { padding: 14px 16px 18px; }
  .gm-how .steps-list li { font-size: 15.5px; padding-inline-start: 46px; }
  .gm-step { padding: 6px 6px; gap: 8px; }
  .gm-step .ic { width: 30px; height: 30px; padding: 7px; }
  .gm-step b { font-size: 14px; }
}
