/* ELCHATEA_DOMINO_SCROLL_V3. Scoped styles; no changes to existing boards. */
#elchateaGamePanel.domino-panel{width:min(720px,calc(100% - 16px))}
#elchateaGamePanel.domino-panel #elchateaGameBoard{display:block}
.ec-dom-board{box-sizing:border-box;width:100%;min-width:0;color:#24475f;font:14px/1.45 'Segoe UI',Arial,sans-serif}
.ec-dom-info,.ec-dom-solo-head{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:9px}
.ec-dom-info{font-size:12px;font-weight:600;color:#567080}
.ec-dom-table{background:#eaf2f7;border:1px solid #c4d7e3;border-radius:10px;padding:10px;margin-bottom:14px}
.ec-dom-ends{font-size:12px;font-weight:700;color:#325e7b;margin-bottom:9px;text-align:center}
.ec-dom-chain{display:block;max-width:100%;min-height:75px;max-height:clamp(180px,40vh,390px);overflow-x:hidden;overflow-y:auto;scrollbar-width:thin;scrollbar-gutter:stable;overscroll-behavior-y:contain;border-radius:5px}
.ec-dom-snake{display:block;width:100%;height:auto}
.ec-dom-table-tile{filter:drop-shadow(0 2px 1px #193c5418)}

.ec-dom-tile{display:block;width:100%;height:auto;filter:drop-shadow(0 2px 1px #193c5418)}
.ec-dom-empty{margin:auto;text-align:center;font-size:13px;color:#577187}
.ec-dom-hand-title{display:block;margin:0 0 7px;font-size:13px}
.ec-dom-hand{display:grid;grid-template-columns:repeat(auto-fit,minmax(64px,1fr));gap:7px;margin:0 0 12px}
.ec-dom-button{font:600 13px/1.3 'Segoe UI',Arial,sans-serif;border:1px solid #b8cbd9;border-radius:6px;min-height:42px;padding:9px 12px;background:#fff;color:#285b80;cursor:pointer;touch-action:manipulation}
.ec-dom-button:hover:not(:disabled){background:#edf4f9}
.ec-dom-button.primary{background:#336699;color:#fff;border-color:#336699}
.ec-dom-button.primary:hover:not(:disabled){background:#275681}
.ec-dom-button:disabled{cursor:default;opacity:.48}
.ec-dom-button:focus-visible,.ec-dom-chain:focus-visible,.ec-dom-rules summary:focus-visible{outline:3px solid #db982e;outline-offset:2px}
.ec-dom-piece{padding:4px;min-width:0;min-height:76px;background:#f8fafc;border:2px solid transparent}
.ec-dom-piece.chosen{border-color:#336699;background:#dcecf8;box-shadow:0 0 0 1px #336699}
.ec-dom-piece .ec-dom-tile{width:100%;max-width:70px;max-height:64px;margin:auto}
.ec-dom-piece .ec-dom-double{width:34px;height:64px}
.ec-dom-actions{display:flex;gap:7px;flex-wrap:wrap;margin:10px 0}
.ec-dom-actions .ec-dom-button{flex:1 1 130px}
.ec-dom-hint,.ec-dom-score{font-size:12px;margin:8px 0;color:#4c6475}
.ec-dom-rules{font-size:12px;margin-top:12px;border-top:1px solid #d9e4ed;padding-top:9px}
.ec-dom-rules summary{cursor:pointer;color:#336699;font-weight:600;min-height:28px}
.ec-dom-rules p{margin:5px 0 0}
.ec-dom-entry{border:1px solid #c9dbe8;background:#f6f9fc;border-radius:9px;padding:14px;margin-bottom:14px;color:#24475f}
.ec-dom-entry strong{font-size:17px}.ec-dom-entry p{font-size:13px;margin:6px 0 11px}
.ec-dom-solo-status{font-weight:700;color:#285b80;margin:6px 0 12px}
#ecDominoSoloRoot{margin-bottom:12px}
@media(max-width:760px){#elchateaGamePanel.domino-panel{left:4px;right:4px;width:auto}.ec-dom-hand{grid-template-columns:repeat(auto-fit,minmax(59px,1fr));gap:5px}.ec-dom-table{padding:8px}.ec-dom-button{min-height:44px}.ec-dom-actions{gap:6px}}

/* Do not let automatic scroll anchoring follow replaced domino controls. */
.ec-dom-board,#ecDominoSoloRoot{overflow-anchor:none}

/* Desktop keeps the V3 layout. The dock has no layout box outside compact mode. */
.ec-dom-dock{display:contents}
.ec-dom-mobile-tools{display:none}
.ec-dom-expanded{box-sizing:border-box;width:calc(100vw - 16px);max-width:960px;height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);padding:0;border:1px solid #739db8;border-radius:10px;background:#eaf2f7;color:#24475f;overflow:hidden}
.ec-dom-expanded::backdrop{background:#102b40b3}
.ec-dom-expanded[open]{display:flex;flex-direction:column}
.ec-dom-expanded-head{display:flex;align-items:center;justify-content:space-between;gap:8px;background:#fff;padding:8px;flex:none}
.ec-dom-expanded-head button{min-height:44px}
.ec-dom-expanded-content{padding:12px;overflow:auto;min-height:0;flex:1;overscroll-behavior:contain}
.ec-dom-expanded-content p{font:16px/1.6 'Segoe UI',Arial,sans-serif;margin:0}
@media (max-width:760px), (pointer:coarse) and (max-width:1100px){
 #elchateaGamePanel.domino-panel,#ecDominoSoloRoot.ec-dom-playing{
  box-sizing:border-box;position:fixed!important;inset:auto 0 0!important;top:var(--ec-dom-view-top,0px)!important;
  width:100%!important;height:var(--ec-dom-view-height,100dvh)!important;max-height:none!important;
  margin:0!important;transform:none!important;border-radius:0;border:0;background:#fff;
  padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);
  display:flex;flex-direction:column;overflow:hidden;
 }
 #ecDominoSoloRoot.ec-dom-playing{z-index:10145}
 #elchateaGamePanel.domino-panel .elchatea-game-panel-header{flex:none;padding:4px 8px;min-height:44px;box-sizing:border-box}
 #elchateaGamePanel.domino-panel .elchatea-game-panel-header button{width:44px;height:44px}
 #elchateaGamePanel.domino-panel .elchatea-game-meta{flex:none;padding:3px 8px}
 #elchateaGamePanel.domino-panel .elchatea-game-actions{flex:none;padding:4px 6px;gap:4px;flex-wrap:nowrap}
 #elchateaGamePanel.domino-panel .elchatea-game-actions button{min-height:44px;min-width:0;padding:4px 6px;font-size:12px}
 #ecDominoSoloRoot.ec-dom-playing>.ec-dom-solo-head{flex:none;margin:0;padding:4px 8px;min-height:44px;box-sizing:border-box;background:#336699;color:#fff}
 #ecDominoSoloRoot.ec-dom-playing>.ec-dom-solo-head strong{font-size:13px}
 #ecDominoSoloRoot.ec-dom-playing>.ec-dom-solo-head button{font-size:12px}
 #ecDominoSoloRoot.ec-dom-playing>.ec-dom-solo-status{flex:none;font-size:13px;margin:0;padding:3px 8px}
 #ecDominoSoloRoot.ec-dom-playing>.ec-dom-actions{flex:none;margin:0;padding:4px 6px;gap:4px}
 #ecDominoSoloRoot.ec-dom-playing>.ec-dom-actions button{flex:1;min-width:0;font-size:12px}
 #elchateaGamePanel.domino-panel #elchateaGameBoard,#ecDominoSoloRoot.ec-dom-playing>.ec-dom-board{
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;
  flex:1;min-height:0;overflow:hidden;padding:4px 8px;gap:4px;align-items:stretch;
 }
 .ec-dom-board>.ec-dom-info{grid-column:1;grid-row:1;flex-wrap:nowrap;gap:4px;margin:0;font-size:11px;min-width:0}
 .ec-dom-mobile-tools{display:inline-flex;gap:3px;margin-left:auto;flex-shrink:0}
 .ec-dom-mobile-tools button{font-size:11px;padding:4px 6px;min-width:44px;min-height:44px}
 .ec-dom-board>.ec-dom-table{grid-column:1;grid-row:2;display:flex;flex-direction:column;min-height:0;min-width:0;margin:0;padding:4px;overflow:hidden}
 .ec-dom-ends{flex:none;font-size:11px;margin:0 0 2px}
 .ec-dom-chain{display:flex;align-items:center;justify-content:center;flex:1;min-height:0;max-height:none;min-width:0;overflow:hidden;scrollbar-gutter:auto;touch-action:manipulation}
 .ec-dom-snake{max-width:100%;max-height:100%;flex:none}
 .ec-dom-board>.ec-dom-dock{display:flex;flex-direction:column;grid-column:1;grid-row:3;min-width:0;min-height:0}
 .ec-dom-hand-title{font-size:12px;margin:0 0 3px}
 .ec-dom-hand{grid-template-columns:repeat(auto-fit,minmax(44px,1fr));gap:3px;margin:0;max-height:clamp(48px,25dvh,200px);overflow:auto;overscroll-behavior:contain;flex-shrink:1;min-height:0}
 .ec-dom-piece{height:48px;min-height:48px;padding:2px}
 .ec-dom-piece .ec-dom-tile{max-width:55px;max-height:40px}
 .ec-dom-piece .ec-dom-double{width:22px;height:40px}
 .ec-dom-dock>.ec-dom-actions{display:flex;flex-wrap:nowrap;gap:3px;margin:4px 0 0;flex:none}
 .ec-dom-dock>.ec-dom-actions button{flex:1 1 0;min-width:0;min-height:44px;font-size:11px;padding:4px}
 .ec-dom-dock>.ec-dom-hint{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
 .ec-dom-dock>.ec-dom-rules{display:none}
 .ec-dom-score{font-size:12px;margin:3px 0}
}
@media (max-height:500px) and (min-width:500px) and (max-width:760px), (max-height:500px) and (min-width:500px) and (pointer:coarse) and (max-width:1100px){
 #elchateaGamePanel.domino-panel #elchateaGameBoard,#ecDominoSoloRoot.ec-dom-playing>.ec-dom-board{grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);column-gap:8px}
 .ec-dom-board>.ec-dom-dock{grid-column:2;grid-row:1 / 3}
 .ec-dom-dock .ec-dom-hand{flex:1;max-height:none;align-content:start}
 .ec-dom-board>.ec-dom-info{flex-wrap:wrap}
 .ec-dom-mobile-tools{margin-left:0}
}

/* V5: touching table faces have a clean shared edge; hand spacing stays touch-friendly. */
.ec-dom-table-tile{filter:none}

/* V6: center natural-sized short chains without stretching their faces. */
.ec-dom-snake{margin-inline:auto}
