/* Mosaic Match — page layout (the same simple layout as Memory Match) */
.cg-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(260px, 1fr); gap: 20px; margin: 18px 0; align-items: start; }
.cg-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin: 18px 0 0; }
.cg-head h1 { font-size: calc(28px * var(--fs, 1)); }
.side { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.buddy { max-width: 240px; margin: 0 auto; width: 100%; }
.bubble { background: var(--raised); border: 2px solid var(--border); border-radius: 14px; padding: 10px 14px; font-weight: 600; min-height: 56px; }
.stat { color: var(--text-2); font-size: calc(16px * var(--fs, 1)); }
.mo-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* today's board carries its date like a small calendar leaf (Khalid 23 Oct 17:03) */
.mo-day { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-2); font-weight: 600; font-size: calc(15px * var(--fs, 1)); }
.mo-leaf { display: inline-flex; flex-direction: column; align-items: center; min-width: 44px; border: 2px solid var(--primary); border-radius: 8px; overflow: hidden; background: var(--card); line-height: 1.1; }
.mo-leaf b { display: block; width: 100%; text-align: center; background: var(--primary); color: var(--card); font: 800 calc(15px * var(--fs, 1)) "Plus Jakarta Sans", sans-serif; padding: 2px 4px; }
.mo-leaf small { font-size: calc(11px * var(--fs, 1)); padding: 1px 4px 2px; color: var(--text); }

/* chain / longest chain / tiles left */
.mo-count { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; font-weight: 600; color: var(--text-2); margin-bottom: 8px; font-size: calc(16px * var(--fs, 1)); }
.mo-count b { color: var(--text); font-family: "Plus Jakarta Sans", sans-serif; }
.mo-chain { padding: 0 10px; border-radius: 999px; border: 2px solid transparent; }
.mo-chain.is-on { border-color: var(--primary); }

/* the board: ivory tiles, radius 10, a very light shadow (spec) */
.mo-board-card { padding: 12px; --mo-tile: #FBF7EC; --mo-edge: #E6DDC8; }
:root[data-theme="dark"] .mo-board-card { --mo-tile: #EDE6D4; --mo-edge: #5C6B64; }
.mo-board { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 8px; margin: 0 auto; max-width: 460px; user-select: none; }
.mo-board-card.is-kids .mo-board { gap: 10px; max-width: 440px; }
.mo-row { display: contents; }
.mo-tile { aspect-ratio: 1; min-width: 56px; padding: 0; border: 1.5px solid var(--mo-edge); border-radius: 10px; background: var(--mo-tile); cursor: pointer; position: relative;
  box-shadow: 0 1px 2px rgba(28, 36, 32, .12); transition: transform .15s ease, box-shadow .15s ease; touch-action: manipulation; }
.mo-tile svg { display: block; width: 100%; height: 100%; border-radius: 9px; }
/* the picked tile: lifted, a solid green ring and a small corner tab (not only a color) */
.mo-tile.is-sel { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--primary), 0 6px 12px rgba(28, 36, 32, .18); border-color: var(--primary); z-index: 1; }
.mo-tile.is-sel::after { content: ""; position: absolute; top: -3px; inset-inline-start: 50%; width: 18px; height: 6px; margin-inline-start: -9px; border-radius: 0 0 6px 6px; background: var(--primary); }
/* «إظهار المشترك»: the tiles that share something glow softly, with a dashed ring (a different line, not only a color) */
.mo-tile.is-glow { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--primary), 0 0 14px rgba(36, 84, 69, .35); outline: 2px dashed var(--primary); outline-offset: -6px; }
/* an empty tile: a quiet place on the board */
.mo-tile.is-empty { background: transparent; border: 1.5px dashed var(--border); box-shadow: none; cursor: default; }
.mo-tile:focus-visible { outline-offset: 2px; }
/* a match: the shared layers fade out in 200 ms (none with reduced motion: they are not drawn at all) */
.mo-out { animation: mo-out .2s ease-out forwards; }
@keyframes mo-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mo-out { display: none; } .mo-tile { transition: none; } }
html.pc-reduce-motion .mo-out { display: none; }
html.pc-reduce-motion .mo-tile { transition: none; }
.mo-days { margin: 0; color: var(--text-2); }

@media (max-width: 900px) and (orientation: portrait), (max-width: 900px) and (max-height: 479px), (max-width: 699px) { .cg-layout { grid-template-columns: 1fr; } }
@media (max-width: 480px) {
  .main-mo { padding: 0 10px; }
  .cg-head h1 { font-size: calc(24px * var(--fs, 1)); }
  .mo-board-card { padding: 8px; }
  .mo-board { gap: 6px; }
}
/* the smallest phones: the tiles keep at least 56px (five across in 320px) */
@media (max-width: 360px) {
  .main-mo { padding: 0 6px; }
  .mo-board-card { padding: 0; border: 0; background: none; box-shadow: none; }
  .mo-board, .mo-board-card.is-kids .mo-board { gap: 4px; }
}

/* Full screen for play (shared mode in core.js / main.css): the tiles as large as the screen allows; the chain above
   (or beside, sideways); a finished board's card sits over the tiles */
:root[data-focus="on"] .mo-board-card { width: min(100cqw, (var(--pc-fy) - 200px) * var(--cols) / var(--rows)); padding: 0; border: 0; background: none; box-shadow: none; align-self: center; }
:root[data-focus="on"] .mo-board { max-width: none; }
:root[data-focus="on"] .mo-count { margin-bottom: 0; }
@media (orientation: landscape) { :root[data-focus="on"] .mo-board-card { width: min(60cqw, (var(--pc-fy) - 12px) * var(--cols) / var(--rows)); } }
/* Wide screens (main.css "Wide screens to play"): the tiles as large as the screen height allows, the chain in the side column */
@media (orientation: landscape) and (min-width: 700px) and (min-height: 480px) {
  :root:not([data-focus="on"]) .cg-layout.pc-wide .mo-board-card { width: min(var(--pc-w), (var(--pc-h) - 24px) * var(--cols) / var(--rows) + 24px); }
  :root:not([data-focus="on"]) .cg-layout.pc-wide .mo-board { max-width: none; }
}
/* Phones (main.css "Phones: everything needed to play"): how small the tiles may get */
.mo-board-card { --pc-phone-min: .8; }
