/* Dominoes — felt table with a snake chain, opponent's tiles and boneyard on top, your hand in a tray below.
 * Geometry: .dm-wrap gets fixed px width/height from domino.js (measured once per window size), so nothing inside can
 * resize or move the board. Theme tokens only (light + dark). */
.dm-wrap {
  --dm-felt: #1f7a64; --dm-felt2: #135646; --dm-felt-line: rgba(255, 255, 255, .13); --dm-felt-ink: #e8fff6;
  --dm-face: #fffaf0; --dm-edge: #d8c9ad; --dm-pip: #1e2636; --dm-div: #cdbd9f; --dm-rivet: #b8873a;
  --dm-bk: #26355a; --dm-bk2: #344a7e; --dm-bk3: #ff6b4a;
  position: relative; display: flex; flex-direction: column; gap: 8px; margin: 0 auto; max-width: 100%;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; contain: layout;
}
:root[data-theme="dark"] .dm-wrap { --dm-felt: #175a4b; --dm-felt2: #0c372d; --dm-face: #ece2cd; --dm-edge: #b3a487; --dm-div: #b9a785; --dm-pip: #171c27; --dm-bk: #1f2c4a; --dm-bk2: #2c3f6b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dm-wrap { --dm-felt: #175a4b; --dm-felt2: #0c372d; --dm-face: #ece2cd; --dm-edge: #b3a487; --dm-div: #b9a785; --dm-pip: #171c27; --dm-bk: #1f2c4a; --dm-bk2: #2c3f6b; }
}
.dm-wrap.side { flex-direction: row; align-items: stretch; }
.dm-pc-brand { --pc: var(--brand); --pcs: var(--brand-soft); }
.dm-pc-blue { --pc: var(--blue); --pcs: var(--blue-soft, rgba(61, 123, 247, .18)); }

/* tile art (inline SVG) */
.dm-f { fill: var(--dm-face); stroke: var(--dm-edge); stroke-width: 2.4; }
.dm-p { fill: var(--dm-pip); }
.dm-d { stroke: var(--dm-div); stroke-width: 2.6; stroke-linecap: round; }
.dm-r { fill: var(--dm-rivet); }
.dm-bk { fill: var(--dm-bk); stroke: rgba(0, 0, 0, .25); stroke-width: 2; }
.dm-bk2 { fill: none; stroke: var(--dm-bk2); stroke-width: 3; }
.dm-bk3 { fill: var(--dm-bk3); }
.dm-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* table */
.dm-table { position: relative; flex: none; border-radius: 22px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 45%, var(--dm-felt) 0%, var(--dm-felt2) 100%);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .14), inset 0 2px 0 6px rgba(255, 255, 255, .04), 0 5px 0 var(--line-2), var(--shadow); }
.dm-table::after { content: ""; position: absolute; inset: 7px; border-radius: 17px; border: 1.5px dashed var(--dm-felt-line); pointer-events: none; }
.dm-top { position: absolute; left: 0; right: 0; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 0 12px; box-sizing: border-box;
  background: linear-gradient(180deg, rgba(0, 0, 0, .16), rgba(0, 0, 0, 0)); }
.dm-info { flex: none; display: flex; flex-direction: column; justify-content: center; color: var(--dm-felt-ink); line-height: 1.15; white-space: nowrap; overflow: hidden; }
.dm-info b { font-size: 13px; font-weight: 800; }
.dm-info small { font-size: 11px; opacity: .78; }
.dm-info small.dm-isc { font-size: 13px; font-weight: 800; opacity: 1; font-variant-numeric: tabular-nums; }
.dm-isc span { color: color-mix(in srgb, var(--pc) 55%, #fff); }
.dm-opp { position: relative; flex: none; height: 100%; }
.dm-ob { position: absolute; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .25)); }
.dm-ob.up { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .3)); }
.dm-cnt { position: absolute; top: 50%; transform: translateY(-50%); min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center;
  font: 800 12px/1 inherit; font-variant-numeric: tabular-nums; color: #fff; background: var(--pc); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.dm-yard { margin-left: auto; flex: none; height: calc(100% - 8px); min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px;
  border-radius: 13px; border: 2px solid rgba(255, 255, 255, .16); background: rgba(0, 0, 0, .18); color: #fff; font: inherit; cursor: default; box-sizing: border-box; }
.dm-yard.go { cursor: pointer; background: var(--brand); border-color: rgba(255, 255, 255, .55); box-shadow: 0 3px 0 rgba(0, 0, 0, .3); animation: dm-pulse 1.1s ease-in-out infinite alternate; }
.dm-yard.go:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.dm-stack { position: relative; width: 30px; height: 24px; flex: none; }
.dm-stack i { position: absolute; left: 0; width: 28px; height: 14px; filter: drop-shadow(0 1.5px 0 rgba(0, 0, 0, .3)); }
.dm-stack i:first-child { top: 9px; }
.dm-stack i:last-child { top: 2px; left: 2px; }
.dm-stack.empty { opacity: .3; }
.dm-yn { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; min-width: 0; }
.dm-yn b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dm-yn small { font-size: 11px; font-weight: 700; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dm-yn { flex: 1 1 auto; overflow: hidden; }

/* chain */
.dm-chain { position: absolute; z-index: 1; }
.dm-ct { position: absolute; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .28)); }
.dm-ct.last::after { content: ""; position: absolute; inset: -3px; border-radius: 7px; box-shadow: 0 0 0 2.5px var(--pc), 0 0 12px var(--pc); pointer-events: none; animation: dm-glow 1.6s ease-out 1 forwards; }
.dm-ghost { position: absolute; z-index: 3; opacity: .62; border-radius: 6px; animation: dm-ghost 1s ease-in-out infinite alternate; }
.dm-ghost::before { content: ""; position: absolute; inset: -4px; border-radius: 8px; border: 2.5px dashed #fff; pointer-events: none; }
.dm-gbtn { position: absolute; inset: -10px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 10px; }
.dm-gbtn:focus-visible { outline: 3px solid #ffd257; outline-offset: -4px; }
.dm-peek { position: absolute; z-index: 2; border-radius: 6px; border: 2px dashed rgba(255, 255, 255, .75); background: rgba(255, 255, 255, .12); pointer-events: none; }
.dm-hint { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 16px; text-align: center; color: var(--dm-felt-ink); font-weight: 700; font-size: 14px; opacity: .85; pointer-events: none; }

/* your hand */
.dm-tray { position: relative; flex: none; border-radius: 18px; background: var(--surface-2); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line-2); box-sizing: border-box; overflow: hidden; }
.dm-tray::before { content: ""; position: absolute; z-index: 1; left: 14px; right: 14px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--pc); opacity: .7; pointer-events: none; }
/* scroller of the hand buttons: sideways only when even two rows of 44 px buttons do not fit (huge hands) */
.dm-hs { position: absolute; inset: 0; overflow: hidden; }
.dm-tray.scroll .dm-hs { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.dm-hsw { display: block; height: 1px; }
/* every button is >= 44 px wide and tall (domino.js handLayout); the tile sits at its bottom with headroom above for the
   lift of a playable / selected tile, so the tray never clips it */
.dm-ht { position: absolute; top: 0; display: flex; align-items: flex-end; justify-content: center; box-sizing: border-box; margin: 0; padding: 0 0 6px; border: 0; background: none; font: inherit; color: inherit; cursor: default; }
.dm-tray.flat .dm-ht { align-items: flex-end; padding-bottom: 5px; }
.dm-tray.flat .dm-ht.ok .dm-tl { transform: translateY(-3px); }
@media (hover: hover) { .dm-tray.flat .dm-ht.ok:hover .dm-tl { transform: translateY(-5px); } }
.dm-tray.flat .dm-ht.sel .dm-tl { transform: translateY(-6px) scale(1.04); }
button.dm-ht { cursor: pointer; }
.dm-tl { display: block; flex: none; border-radius: 6px; transition: transform .18s var(--spring, ease), opacity .2s; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .2)); }
.dm-ht.ok .dm-tl { transform: translateY(-5px); filter: drop-shadow(0 0 0 var(--pc)) drop-shadow(0 4px 0 color-mix(in srgb, var(--pc) 70%, #000)); }
.dm-ht.ok .dm-tl svg .dm-f { stroke: var(--pc); stroke-width: 3.4; }
@media (hover: hover) { .dm-ht.ok:hover .dm-tl { transform: translateY(-9px); } }
.dm-ht.no .dm-tl { opacity: .45; }
.dm-ht.sel .dm-tl { transform: translateY(-11px) scale(1.05); }
.dm-ht.sel .dm-tl svg .dm-f { fill: color-mix(in srgb, var(--dm-face) 82%, #ffd257); }
.dm-ht:focus-visible { outline: none; }
.dm-ht:focus-visible .dm-tl { box-shadow: 0 0 0 3px var(--pc), 0 0 0 6px var(--pcs); }
.dm-ht.new .dm-tl { animation: dm-new 1.2s ease-out 1; }
.dm-drawpill { position: absolute; left: 50%; bottom: 14px; z-index: 5; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 18px 8px 12px;
  border: 0; border-radius: 999px; background: var(--brand); color: #fff; font: inherit; font-weight: 800; font-size: 15px; white-space: nowrap; cursor: pointer;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--brand) 60%, #000), 0 8px 18px rgba(0, 0, 0, .25); animation: dm-pop .3s var(--spring, ease) 1; }
.dm-drawpill span { display: block; width: 30px; height: 15px; }
.dm-drawpill:active { transform: translate(-50%, 2px); }
.dm-drawpill:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* hand summary (overlay inside the table: it never moves anything) */
.dm-sum { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 8px; box-sizing: border-box; background: rgba(8, 22, 18, .5); animation: dm-fade .25s ease-out 1; }
.dm-sbox { position: relative; width: min(100%, 440px); max-height: 100%; overflow: hidden; box-sizing: border-box; padding: 10px 12px 12px; border-radius: 18px; text-align: center;
  background: var(--surface); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 6px 0 var(--line-2), 0 18px 40px rgba(0, 0, 0, .35); animation: dm-pop .32s var(--spring, ease) 1; }
.dm-sbox h3 { margin: 0 0 2px; font-size: clamp(16px, 4.6vw, 21px); line-height: 1.2; }
.dm-sum.won .dm-sbox h3 { color: var(--brand); }
.dm-swhy { margin: 0 0 6px; font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
.dm-srow { display: grid; grid-template-columns: minmax(0, 5.5em) minmax(0, 1fr) auto; gap: 6px; align-items: center; margin: 3px 0; padding: 4px 8px; border-radius: 10px; background: var(--surface-2); text-align: left; font-size: 12.5px; }
.dm-srow > b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pc); }
.dm-stiles { display: flex; flex-wrap: wrap; gap: 2px; min-width: 0; max-height: 36px; overflow: hidden; }
.dm-stiles i { display: block; width: 30px; height: 15px; }
.dm-stiles em { font-style: normal; color: var(--ink-3); }
.dm-spips { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dm-sscore { margin: 6px 0 4px; display: flex; align-items: baseline; justify-content: center; gap: 6px; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dm-sscore span { color: var(--pc); }
.dm-sscore i { font-style: normal; color: var(--ink-3); }
.dm-sscore small { font-size: 12px; font-weight: 700; color: var(--ink-3); margin-left: 4px; }
.dm-next { min-height: 44px; padding-inline: 22px; }
.dm-sum.compact { padding: 6px; }
.dm-sum.compact .dm-sbox { padding: 6px 10px 8px; overflow-y: auto; }   /* a very short table: the box scrolls rather than hiding the score and the button */
.dm-sum.compact h3 { font-size: 15px; }
.dm-sum.compact .dm-swhy { margin-bottom: 3px; font-size: 11.5px; }
.dm-sum.compact .dm-srow { margin: 1px 0; padding: 2px 8px; grid-template-columns: minmax(0, 1fr) auto; }
.dm-sum.compact .dm-stiles, .dm-sum.compact .dm-sbar { display: none; }
.dm-sum.compact .dm-sfoot { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 4px; }
.dm-sum.compact .dm-sscore { margin: 0; font-size: 18px; }
.dm-sbar { display: block; height: 3px; margin: 8px auto 0; width: 60%; border-radius: 2px; background: var(--brand); transform-origin: left; opacity: .7; }

@keyframes dm-pulse { from { box-shadow: 0 3px 0 rgba(0, 0, 0, .3), 0 0 0 0 color-mix(in srgb, var(--brand) 60%, transparent); } to { box-shadow: 0 3px 0 rgba(0, 0, 0, .3), 0 0 0 6px color-mix(in srgb, var(--brand) 0%, transparent); } }
@keyframes dm-glow { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: .55; } }
@keyframes dm-ghost { from { opacity: .45; } to { opacity: .8; } }
@keyframes dm-new { 0% { box-shadow: 0 0 0 0 #ffd257; } 30% { box-shadow: 0 0 0 4px #ffd257; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes dm-pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes dm-fade { from { opacity: 0; } to { opacity: 1; } }
.dm-drawpill { animation-name: dm-pill; }
@keyframes dm-pill { from { transform: translateX(-50%) scale(.85); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .dm-wrap *, .dm-wrap *::before, .dm-wrap *::after { animation: none !important; transition: none !important; }
}

/* wave16 fix: rooms and the vs-computer page on phones held sideways. games.css makes the two player bars compact chips
   on one row with the status line (as for Mangala), so the board takes the full width under them: domino.js then lays
   the hand beside a much taller table (it was 270x116 px with 8 px chain tiles in the square-board column). Fixed
   column shares, so nothing moves when the status text changes. */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  body.in-room #boardPanel:has(> #board > .dm-wrap) { grid-template-columns: minmax(120px, 1fr) minmax(0, 1.5fr) minmax(120px, 1fr); }
  body.in-room #boardPanel:has(> #board > .dm-wrap) > #status { grid-row: 1; grid-column: 2; display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 22px; }
  body.in-room #boardPanel:has(> #board > .dm-wrap) > #board { width: 100%; }
}
/* wave18: small phones held sideways (568x320, 640x360): as on Mangala, the chips take the larger shares (the
   opponent's name was cut after 3-9 letters at 143 / 164 px) and the status line may use two lines of the 32 px chip
   row. Fixed shares and a fixed height: no status text or score moves anything; the board row is not touched. */
@media (max-width: 640px) and (max-height: 500px) and (orientation: landscape) {
  body.in-room #boardPanel:has(> #board > .dm-wrap) { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.3fr); column-gap: 8px; }
  body.in-room #boardPanel:has(> #board > .dm-wrap) > #status { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; height: 30px; line-height: 15px; font-size: 12.5px; text-align: center; text-overflow: clip; overflow-wrap: anywhere; }
  body.in-room #boardPanel:has(> #board > .dm-wrap) .pbar { gap: 6px; padding-right: 8px; }
  body.in-room #boardPanel:has(> #board > .dm-wrap) .pbar .ptag .typing { gap: 3px; }
  body.in-room #boardPanel:has(> #board > .dm-wrap) .pbar .ptag .typing i { width: 5px; height: 5px; }
}
