/* KulliQ — ذاكرة الصور: a memory game for children from 6 to 9, the first of the section's brain games. A violet table
   (the section's logo tile), cards whose back is that tile with its rainbow and its star, warm white faces with a 3D
   picture (Fluent Emoji) or a word. The first screen and «المزيد» follow «المزرعة السحرية» (games/farm/farm.css), kept
   here so each game stands on its own. */
:root {
  --ink: #1B2A4A; --soft: #4C5B7A; --panel: #FFFFFF; --chip: #F3F0FF; --chipLine: #E2DBFB;
  --sun: #FFD23F; --sunD: #E0A800; --sunInk: #3A2600;
  --coral: #FF6B6B; --coralD: #D94848; --sky: #4CC9F0; --skyD: #1E9AC6; --mint: #3DDC97; --mintD: #1FA874; --pink: #FF4D6D;
  --violet: #6C4BFF; --edge: #22186B; --wordInk: #3B2AA0; --enInk: #1F6FD1; --faceEdge: #CDBFF7;
  --display: "Baloo Bhaijaan 2", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --sprite: url(pics.webp?v=1);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sparkles: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 260'%3E%3Cg fill='%23fff'%3E%3Cpath d='M40 30 Q40 40 50 40 Q40 40 40 50 Q40 40 30 40 Q40 40 40 30Z' opacity='.32'/%3E%3Cpath d='M200 70 Q200 76 206 76 Q200 76 200 82 Q200 76 194 76 Q200 76 200 70Z' opacity='.28'/%3E%3Cpath d='M120 196 Q120 205 129 205 Q120 205 120 214 Q120 205 111 205 Q120 205 120 196Z' opacity='.24'/%3E%3Ccircle cx='150' cy='30' r='2' opacity='.32'/%3E%3Ccircle cx='232' cy='176' r='2.4' opacity='.28'/%3E%3Ccircle cx='28' cy='150' r='1.8' opacity='.28'/%3E%3Ccircle cx='92' cy='110' r='1.5' opacity='.22'/%3E%3Ccircle cx='206' cy='238' r='1.5' opacity='.22'/%3E%3C/g%3E%3C/svg%3E");
  --table: var(--sparkles) 0 0 / 260px 260px, radial-gradient(70% 45% at 85% -8%, rgba(176, 150, 255, .55), transparent 70%),
    radial-gradient(70% 40% at 0% 108%, rgba(59, 180, 255, .4), transparent 70%), linear-gradient(165deg, #5B3FE6 0%, #4330BF 50%, #2B2496 100%);
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --tickInk: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%233A2600' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 0 Q10 10 20 10 Q10 10 10 20 Q10 10 0 10 Q10 10 10 0Z' fill='%23FFF4A8'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #4330BF; color: #fff; font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- a picture from the game's sprite (pics.webp: memory.js sets --pp, its place, and --ps, the sprite's size) ---- */
.pic { display: block; width: 74%; aspect-ratio: 1; background: var(--sprite) var(--pp, 0 0) / var(--ps, 800% 800%) no-repeat; filter: drop-shadow(0 4px 4px rgba(27, 42, 74, .2)); }
.tile { position: relative; display: block; border-radius: 28%; background: #fff; box-shadow: 0 3px 0 var(--faceEdge); }
.tile::before, .av::before, .crown::before { content: ""; position: absolute; inset: 10%; background: var(--sprite) var(--pp, 0 0) / var(--ps, 800% 800%) no-repeat; }
.word { font: 800 var(--fs, 27cqw)/1.5 var(--display); color: var(--wordInk); text-align: center; padding: 0 5%; }
.en { direction: ltr; font: 800 var(--fs, 19cqw)/1.15 var(--display); color: var(--enInk); text-align: center; padding: 0 5%; }
.av { position: relative; display: block; flex: none; width: 36px; height: 36px; border-radius: 50%; background: #FFF4E2; box-shadow: 0 0 0 2.5px var(--c, var(--coral)); }
.av::before { inset: 9%; }

/* ---- the first screen: the name, what to pair, how many play, and a big «ابدأ اللعب» ---- */
.setup { position: relative; min-height: 100vh; min-height: 100dvh; background: var(--table); background-attachment: fixed; }
.first { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(var(--sat) + 72px) 16px calc(var(--sab) + 26px); max-width: 560px; margin: 0 auto; }
.setup.open .first { min-height: 0; padding-bottom: 16px; }
.goBack { position: absolute; top: calc(var(--sat) + 16px); inset-inline-start: 16px; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; font-weight: 600; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .24); }
.goBack:hover { background: rgba(255, 255, 255, .22); }
.mc { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 5 / 6; border-radius: 15% / 12.5%; container-type: inline-size; }
.mc.face { background: linear-gradient(180deg, #FFFFFF 0%, #FFF6E6 100%); box-shadow: 0 5px 0 var(--faceEdge), 0 10px 14px rgba(12, 8, 60, .35); }
.mc.back { box-shadow: 0 5px 0 var(--edge), 0 10px 12px rgba(10, 6, 50, .35); }
.mc.back svg { display: block; width: 100%; height: 100%; }
.fan { position: relative; width: 272px; height: 150px; flex: none; }
.fan .mc { position: absolute; width: 98px; top: 16px; }
.fan .f1 { right: 14px; transform: rotate(13deg); }
.fan .f2 { left: 87px; top: 0; z-index: 2; animation: bob 4s ease-in-out infinite; }
.fan .f3 { left: 14px; transform: rotate(-13deg); }
.glow { position: absolute; inset: -20px -30px; background: radial-gradient(closest-side, rgba(255, 230, 140, .35), transparent); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.ttlWrap { margin: -6px 0 0; line-height: 0; }
.ttl { width: min(318px, 82vw); aspect-ratio: 760 / 210; overflow: visible; }
.sub { margin: -10px 0 0; font-size: 17px; font-weight: 600; opacity: .9; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.mode { position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 14px 4px 11px; border-radius: 20px; border: 0;
  background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .22); color: #fff; font-size: 15px; font-weight: 700; }
.mode:hover, .pl:hover { background: rgba(255, 255, 255, .2); }
.mode[aria-checked="true"], .pl[aria-checked="true"] { background: #fff; color: var(--wordInk); box-shadow: 0 6px 0 var(--faceEdge), 0 12px 20px rgba(12, 8, 60, .3); }
.mode[aria-checked="true"]::after, .pl[aria-checked="true"]::after { content: ""; position: absolute; top: -8px; inset-inline-end: -6px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--sun) var(--tickInk) center / 16px no-repeat; box-shadow: 0 2px 0 var(--sunD); }
.mini { display: flex; gap: 5px; }
.mini .mc { width: 40px; }
.mini .mc.face { box-shadow: 0 3px 0 var(--faceEdge); }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.pl { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; border-radius: 18px; border: 0;
  background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .22); color: #fff; font-size: 16px; font-weight: 700; }
.pl .av + .av { margin-inline-start: -12px; }
.start { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 22px; padding: 15px 0 12px;
  background: var(--sun); color: var(--sunInk); box-shadow: 0 7px 0 var(--sunD), 0 14px 28px rgba(12, 8, 60, .35); font: 800 30px/1.2 var(--display); }
.start:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--sunD); }
.first .start { animation: nudge 3s ease-in-out 1.5s infinite; }
.first .start:active { animation: none; }
@keyframes nudge { 0%, 76%, 100% { transform: scale(1); } 84% { transform: scale(1.045); } 92% { transform: scale(.99); } }
.lvl { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; opacity: .9; text-align: center; }
.lvl svg { flex: none; }
.moreBtn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 20px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 16px; font-weight: 700; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .22); }
.moreBtn:hover { background: rgba(255, 255, 255, .22); }
.moreBtn svg { transition: transform .2s; }
.moreBtn[aria-expanded="true"] svg { transform: rotate(180deg); }
.mode:focus-visible, .pl:focus-visible, .start:focus-visible, .moreBtn:focus-visible, .goBack:focus-visible, .round:focus-visible, .lv:focus-visible, .switch:focus-visible,
.plBtn:focus-visible, .again:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

/* «المزيد»: white cards on the table */
.more { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 0 16px calc(var(--sab) + 44px); }
.sCard { width: min(700px, 100%); background: var(--panel); color: var(--ink); border-radius: 26px; padding: 22px clamp(16px, 4vw, 28px); display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 10px 0 rgba(34, 24, 107, .35), 0 16px 30px rgba(12, 8, 60, .3); }
.sCard h2 { margin: 0; font: 800 24px/1.3 var(--display); color: var(--wordInk); }
.levels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.lv { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 2px 9px; border-radius: 16px; border: 2px solid var(--chipLine); background: var(--chip);
  color: var(--wordInk); font: 800 24px/1 var(--display); }
.lv:hover:not(:disabled) { border-color: #C9BCFA; }
.lv[aria-current="true"] { border-color: var(--violet); background: #E9E3FF; box-shadow: 0 4px 0 #C2B4FA; }
.lv:disabled { cursor: default; color: #A49BC6; background: #F7F5FC; }
.lv .st { display: flex; gap: 1px; height: 15px; align-items: center; }
.lv .st svg { width: 15px; height: 15px; }
.lv .lk { width: 16px; height: 16px; color: #B5ACD6; }
.hintLine { margin: -6px 0 0; color: var(--soft); font-size: 14px; line-height: 1.7; }
.soundRow { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.soundRow > div { display: flex; flex-direction: column; gap: 2px; }
.soundRow b { font-size: 17px; font-weight: 700; }
.soundRow span { color: var(--soft); font-size: 14px; }
.switch { flex: 0 0 64px; height: 36px; border-radius: 18px; border: 0; padding: 4px; background: #C8D3E6; display: flex; justify-content: flex-start; }
.switch span { width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch[aria-checked="true"] { background: var(--mint); justify-content: flex-end; }
.plBtn { min-height: 48px; border: 0; border-radius: 14px; background: var(--chip); color: var(--wordInk); font-size: 16px; font-weight: 700; box-shadow: inset 0 0 0 2px var(--chipLine); }
.notes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; color: var(--soft); font-size: 15px; line-height: 1.7; }
.notes li { display: flex; align-items: flex-start; gap: 10px; }
.notes svg { flex: 0 0 20px; margin-top: 3px; }
@media (pointer: coarse) { .kbOnly { display: none !important; } }
.also { width: min(700px, 100%); display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.also a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 999px; background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none;
  font-size: 15px; font-weight: 600; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .22); }
.also a:hover { background: rgba(255, 255, 255, .24); }
.credits { margin: 0; font-size: 13px; opacity: .78; text-align: center; }
.credits a { color: #fff; }

/* ---- a round ---- */
.play { position: fixed; inset: 0; overflow: hidden; background: var(--table); user-select: none; -webkit-user-select: none;
  --top: calc(var(--sat) + 10px); --t: calc(var(--sat) + 146px); --b: calc(var(--sab) + 84px); --l: 14px; --r: 14px; }
.bar { position: absolute; top: var(--top); left: 14px; right: 14px; height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 10px; z-index: 6; }
.round { width: 52px; height: 52px; flex: none; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .26); }
.round:hover { background: rgba(255, 255, 255, .24); }
.round svg { display: block; }
.lvlPill { display: flex; flex-direction: column; align-items: center; line-height: 1.15; text-align: center; min-width: 0; }
.lvlPill b { font: 800 25px/1.2 var(--display); }
.lvlPill span { font-size: 14px; font-weight: 600; opacity: .85; white-space: nowrap; }
.hint { position: absolute; top: calc(var(--top) + 60px); inset-inline-start: 14px; z-index: 9; padding: 8px 14px; border-radius: 14px; background: #fff; color: var(--wordInk);
  font-size: 14px; font-weight: 700; box-shadow: 0 6px 18px rgba(12, 8, 60, .35); }
.tray { position: absolute; top: calc(var(--top) + 66px); left: 14px; right: 14px; height: 60px; border-radius: 18px; background: rgba(255, 255, 255, .1);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .18); display: flex; align-items: center; justify-content: center; gap: var(--sg, 8px); padding: 0 10px; }
.slot { flex: none; width: var(--ss, 42px); aspect-ratio: 1; border-radius: 28%; border: 2px dashed rgba(255, 255, 255, .34); }
.slot.tile { border: 0; animation: land .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes land { from { transform: scale(.2); } to { transform: scale(1); } }

/* the cards: a 3D flip; the back is the section's tile, the face warm white */
.board { position: absolute; top: var(--t); bottom: var(--b); left: var(--l); right: var(--r); display: flex; align-items: center; justify-content: center; }
.grid { display: grid; grid-template-columns: repeat(var(--cols, 3), var(--cw, 100px)); gap: var(--gap, 12px); }
.card { position: relative; display: block; width: var(--cw, 100px); aspect-ratio: 5 / 6; padding: 0; border: 0; background: none; border-radius: 15% / 12.5%;
  perspective: 900px; container-type: inline-size; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform .25s ease; }
.card:focus-visible { outline: 3px solid var(--sun); outline-offset: 4px; }
.card .in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .42s cubic-bezier(.3, 1.25, .5, 1); }
.card.open .in { transform: rotateY(180deg); }
.card .b, .card .f { position: absolute; inset: 0; border-radius: 15% / 12.5%; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.card .b { box-shadow: 0 5px 0 var(--edge), 0 10px 14px rgba(10, 6, 50, .35); }
.card .b svg { display: block; width: 100%; height: 100%; }
.card:not(.open):hover .b { filter: brightness(1.08); }
.card .f { transform: rotateY(180deg); background: linear-gradient(180deg, #FFFFFF 0%, #FFF6E6 100%); box-shadow: 0 5px 0 var(--faceEdge), 0 10px 14px rgba(12, 8, 60, .3);
  display: flex; align-items: center; justify-content: center; }
/* found: a ring and a tick (two players: the finder's colour); just found: lifted and glowing */
.card.got .f { box-shadow: 0 0 0 4px var(--mint), 0 6px 0 4px var(--mintD), 0 10px 14px rgba(12, 8, 60, .3); }
.card.got .f::after { content: ""; position: absolute; top: -8%; inset-inline-end: -8%; width: clamp(16px, 26cqw, 28px); aspect-ratio: 1; border-radius: 50%;
  background: var(--mint) var(--tick) center / 62% no-repeat; box-shadow: 0 2px 0 var(--mintD); }
.card.p1 .f { box-shadow: 0 0 0 4px var(--coral), 0 6px 0 4px var(--coralD), 0 10px 14px rgba(12, 8, 60, .3); }
.card.p2 .f { box-shadow: 0 0 0 4px var(--sky), 0 6px 0 4px var(--skyD), 0 10px 14px rgba(12, 8, 60, .3); }
.card.now { z-index: 2; transform: translateY(-4px) scale(1.05); }
.card.now .f { box-shadow: 0 0 0 5px var(--sun), 0 7px 0 5px var(--sunD), 0 0 30px 8px rgba(255, 214, 70, .55); }
.card.shake { animation: shake .42s ease; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* the word said aloud, under the cards */
.sayRow { position: absolute; left: var(--l); right: var(--r); bottom: calc(var(--sab) + 16px); display: flex; justify-content: center; pointer-events: none; z-index: 7; }
.say { display: flex; align-items: center; gap: 12px; padding-block: 7px; padding-inline: 8px 26px; border-radius: 999px; background: #fff; color: var(--wordInk);
  box-shadow: 0 6px 0 var(--faceEdge), 0 14px 24px rgba(12, 8, 60, .35); white-space: nowrap; animation: rise .35s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes rise { from { transform: translateY(14px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.say .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--violet); color: #fff; display: grid; place-items: center; }
.say b { font: 800 30px/1.3 var(--display); }
.say b[dir="ltr"] { color: var(--enInk); }
.say small { font: 700 20px/1.3 var(--display); color: var(--soft); }

/* the players: held upright, a row of two at the top; held sideways, a panel on each side */
.side { position: absolute; display: none; z-index: 5; color: #fff; }
.play.two .side.p1, .play.two .side.p2, .play.wide:not(.two) .side.solo { display: flex; }
.play.two .tray, .play.wide .tray { display: none; }
.side .av { --c: var(--coral); --d: var(--coralD); }
.side.p2 .av { --c: var(--sky); --d: var(--skyD); }
.side .badge { display: none; padding: 2px 12px; border-radius: 999px; background: var(--coral); color: #fff; font: 800 15px/1.4 var(--display); box-shadow: 0 3px 0 var(--coralD); }
.side.p2 .badge { background: var(--sky); box-shadow: 0 3px 0 var(--skyD); }
.side.turn .badge { display: inline-block; animation: rise .35s ease; }
.side .name { font: 800 20px/1.2 var(--display); }
.side .score { font: 800 34px/1 var(--display); color: var(--sun); text-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.side .pairs, .side .label { font-size: 14px; font-weight: 600; opacity: .85; }
.side .found { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.side .found .tile { width: 40px; height: 40px; }
.play.two:not(.wide) .side { top: calc(var(--top) + 66px); height: 62px; width: calc(50% - 19px); flex-direction: row; align-items: center; gap: 10px; padding: 0 12px;
  border-radius: 18px; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .18); opacity: .72; transition: opacity .2s, background .2s; }
.play.two:not(.wide) .side.p1 { inset-inline-start: 14px; }
.play.two:not(.wide) .side.p2 { inset-inline-end: 14px; }
.play.two:not(.wide) .side .av { width: 42px; height: 42px; box-shadow: 0 0 0 3px var(--c); }
.play.two:not(.wide) .side .who { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; flex: 1; }
.play.two:not(.wide) .side .name { font-size: 18px; }
.play.two:not(.wide) .side .badge { font-size: 13px; padding: 0 10px; }
.play.two:not(.wide) .side .pairs, .play.two:not(.wide) .side .found { display: none; }
.play.two:not(.wide) .side.turn { opacity: 1; background: rgba(255, 107, 107, .2); box-shadow: inset 0 0 0 3px var(--coral), 0 0 24px rgba(255, 107, 107, .35); }
.play.two:not(.wide) .side.p2.turn { background: rgba(76, 201, 240, .2); box-shadow: inset 0 0 0 3px var(--sky), 0 0 24px rgba(76, 201, 240, .35); }
.play.wide { --pw: clamp(150px, 20vw, 262px); --t: calc(var(--sat) + 78px); --b: calc(var(--sab) + 92px); --l: 24px; --r: calc(var(--pw) + 40px); }
.play.wide.two { --l: calc(var(--pw) + 40px); }
.play.wide .side { top: calc(var(--top) + 96px); width: var(--pw); flex-direction: column; align-items: center; gap: 8px; padding: 22px 14px 20px; border-radius: 30px;
  background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .14); text-align: center; }
.play.wide .side.p1, .play.wide .side.solo { inset-inline-start: 22px; }
.play.wide .side.p2 { inset-inline-end: 22px; }
.play.wide.two .side { opacity: .72; transition: opacity .2s, background .2s, box-shadow .2s; }
.play.wide.two .side.turn { opacity: 1; background: rgba(255, 107, 107, .16); box-shadow: inset 0 0 0 3px var(--coral), 0 0 46px rgba(255, 107, 107, .4); }
.play.wide.two .side.p2.turn { background: rgba(76, 201, 240, .16); box-shadow: inset 0 0 0 3px var(--sky), 0 0 46px rgba(76, 201, 240, .4); }
.play.wide .side .av { width: clamp(80px, 9vw, 128px); height: clamp(80px, 9vw, 128px); box-shadow: 0 0 0 6px var(--c), 0 9px 0 6px var(--d); margin-bottom: 12px; }
.play.wide .side .who { display: flex; flex-direction: column; align-items: center; gap: 6px; order: 0; }
.play.wide .side .name { font-size: clamp(22px, 2.4vw, 30px); }
.play.wide .side .score { font-size: clamp(44px, 5vw, 66px); }
.side.solo .miniBuddy { width: clamp(70px, 8vw, 104px); height: clamp(70px, 8vw, 104px); filter: drop-shadow(0 8px 10px rgba(12, 8, 60, .3)); margin-bottom: 4px; }
/* a short screen keeps every row for the cards: the word said aloud shows at the top instead */
@media (orientation: landscape) and (max-height: 560px) {
  .play.wide { --t: calc(var(--sat) + 70px); --b: 12px; }
  .sayRow { top: var(--top); bottom: auto; }
  .say { padding-block: 3px; }
  .say .ic { width: 36px; height: 36px; }
  .say b { font-size: 25px; }
  .play.wide .side { top: calc(var(--top) + 66px); padding: 12px 10px; gap: 4px; }
  .play.wide .side .av { width: 60px; height: 60px; box-shadow: 0 0 0 4px var(--c), 0 6px 0 4px var(--d); margin-bottom: 6px; }
  .play.wide .side .score { font-size: 38px; }
  .play.wide .side .found .tile { width: 30px; height: 30px; }
  .side.solo .miniBuddy { width: 54px; height: 54px; }
}
@media (orientation: portrait) and (max-height: 700px) {
  .play { --t: calc(var(--sat) + 126px); --b: 12px; }
  .tray { height: 46px; top: calc(var(--top) + 62px); }
  .play.two:not(.wide) .side { top: calc(var(--top) + 60px); height: 54px; }
  .play.two:not(.wide) .side .av { width: 36px; height: 36px; }
  .sayRow { top: calc(var(--top) + 62px); bottom: auto; }
  .say { padding-block: 3px; }
  .say .ic { width: 36px; height: 36px; }
  .say b { font-size: 25px; }
}

/* sparkles when a pair is found, confetti at the end */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.spark { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; background: var(--spark) center / contain no-repeat; filter: drop-shadow(0 0 4px rgba(255, 230, 120, .9));
  animation: spark .8s ease-out forwards; }
@keyframes spark { from { transform: translate(0, 0) scale(.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.15); opacity: 0; } }
.conf { position: absolute; top: -24px; width: 10px; height: 16px; border-radius: 3px; animation: fall var(--d, 3s) linear forwards; }
@keyframes fall { to { transform: translate(var(--dx, 0), 112vh) rotate(var(--rot, 360deg)); } }

/* ---- the end of a round ---- */
.doneWrap { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: calc(var(--sat) + 96px) 16px calc(var(--sab) + 20px);
  overflow-y: auto; background: rgba(20, 12, 70, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.panel { position: relative; width: min(390px, 100%); margin: auto; padding: 76px 20px 22px; border-radius: 34px; background: #fff; color: var(--ink); text-align: center;
  box-shadow: 0 10px 0 var(--faceEdge), 0 26px 50px rgba(12, 8, 60, .45); display: flex; flex-direction: column; align-items: center; gap: 12px; animation: rise .45s cubic-bezier(.3, 1.4, .5, 1); }
.buddy { position: absolute; top: -80px; left: 50%; width: 144px; height: 144px; margin-left: -72px; filter: drop-shadow(0 10px 12px rgba(12, 8, 60, .35)); overflow: visible;
  animation: cheer 1.6s ease-in-out infinite; }
@keyframes cheer { 0%, 100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(6deg) translateY(-6px); } }
.wow { width: min(250px, 70vw); height: 92px; overflow: visible; }
.stars3 { display: flex; align-items: flex-end; gap: 4px; margin-top: -4px; }
.stars3 svg { width: 66px; height: 66px; overflow: visible; }
.stars3 .mid { width: 88px; height: 88px; margin-bottom: 12px; }
.stars3 svg.on { animation: starIn .5s cubic-bezier(.3, 1.6, .5, 1) both; }
.stars3 svg:nth-child(2).on { animation-delay: .2s; }
.stars3 svg:nth-child(3).on { animation-delay: .4s; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.vs { display: flex; gap: 28px; align-items: flex-end; }
.vsP { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--soft); font-weight: 700; }
.vsP .av { width: 74px; height: 74px; box-shadow: 0 0 0 4px var(--c), 0 6px 0 4px var(--d); margin-bottom: 8px; }
.vsP.p1 .av { --c: var(--coral); --d: var(--coralD); }
.vsP.p2 .av { --c: var(--sky); --d: var(--skyD); }
.vsP b { font: 800 34px/1 var(--display); color: var(--wordInk); }
.vsP .crown { display: none; position: absolute; top: -34px; left: 50%; width: 48px; height: 48px; margin-left: -24px; transform: rotate(-10deg); }
.vsP.win .crown { display: block; animation: starIn .5s cubic-bezier(.3, 1.6, .5, 1) .2s both; }
.vsP.win .av { width: 88px; height: 88px; }
.panel p { margin: 0; font-size: 18px; font-weight: 600; color: var(--soft); }
.panel p b { color: var(--wordInk); font-weight: 700; }
.doneFound { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 320px; }
.doneFound .tile { width: 42px; height: 42px; background: #F3EEFF; box-shadow: none; }
.panel .start { margin-top: 6px; font-size: 26px; }
.again { width: 100%; min-height: 54px; border-radius: 18px; border: 0; background: #F1EDFF; color: var(--wordInk); font-size: 18px; font-weight: 700; box-shadow: 0 4px 0 #D9D0FA; }
.again:active { transform: translateY(3px); box-shadow: 0 1px 0 #D9D0FA; }

@media (max-width: 380px) {
  .first { gap: 12px; }
  .fan { transform: scale(.88); margin: -8px 0; }
  .mode { font-size: 14px; }
  .start { font-size: 27px; }
  .levels { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 520px) { .levels { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* a short phone: the cards of the first screen a little smaller, so «المزيد» shows too */
@media (max-height: 700px) {
  .first { gap: 10px; padding-top: calc(var(--sat) + 64px); }
  .fan { width: 240px; height: 128px; }
  .fan .mc { width: 84px; }
  .fan .f2 { left: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  .card .in, .card { transition: none; }
  .card.shake, .first .start, .fan .f2, .buddy, .say, .panel, .slot.tile, .stars3 svg.on, .vsP.win .crown { animation: none; }
}
