/* Optional Table Play. Independent from house rules and coaching preferences. */
.table-play-setting {
  margin: 1rem 0;
  background: #f3f5eb;
  border-color: #a7b89e;
}
.table-play-setting .rules-card-heading { min-height: 0; }
.table-play-setting .rule-toggle { margin-top: .3rem; border-bottom: 0; padding-bottom: .5rem; }
.table-play-setting > p { margin: .25rem 0 0 1.8rem; color: #526153; font: .8rem/1.55 var(--sans); }
.table-play-setting:has(input:checked) { border-color: #587850; box-shadow: inset 4px 0 #587850; }
.table-play-setting .rule-toggle:focus-within { outline: 3px solid #a76b27; outline-offset: 4px; border-radius: 3px; }

/* Only the editor scrolls: the title, cancel and commit controls remain visible. */
.table-play-dialog {
  box-sizing: border-box;
  width: min(900px, calc(100vw - 24px));
  max-width: none;
  max-height: 90vh;
  max-height: 90dvh;
  padding: 0;
  border: 1px solid #c3ae7e;
  border-radius: 14px;
  overflow: hidden;
  color: #233f31;
  background: #fffdf5;
  box-shadow: 0 24px 80px #061f1ad9;
  font: 400 16px/1.5 var(--sans);
}
.table-play-dialog[open] { display: flex; flex-direction: column; }
.table-play-dialog::backdrop { background: #0b2723c4; }
.table-play-dialog > header,
.table-play-dialog > footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  background: #f1eedf;
}
.table-play-dialog > header { border-bottom: 1px solid #d5cfbb; }
.table-play-dialog > header > div { min-width: 0; }
.table-play-dialog > header .game-kicker { margin: 0 0 .15rem; color: #756035; font: 800 .65rem/1.4 var(--sans); letter-spacing: .11em; }
.table-play-dialog h2 { margin: 0; font: 500 clamp(1.35rem, 2.5vw, 1.9rem)/1.2 var(--serif); overflow-wrap: anywhere; }
.table-play-dialog > footer { border-top: 1px solid #d5cfbb; justify-content: flex-end; }
.table-play-dialog .game-button { min-height: 44px; margin: 0; padding: .65rem .9rem; font: 700 .85rem/1.3 var(--sans); white-space: normal; }
.table-play-dialog > header .game-button { flex: 0 0 auto; }
.table-play-dialog button:focus-visible { outline: 3px solid #a66726; outline-offset: 3px; }
.table-convert-call { border-color: #496e5c; }
.table-conversion-help { margin: .55rem 0 0; color: #4c5b51; font-size: .875rem; line-height: 1.5; }
.table-reference-dialog { width: min(1440px, calc(100vw - 24px)); }
.table-reference-help { flex: 0 0 auto; margin: 0; padding: .65rem 1.25rem; border-bottom: 1px solid #d5cfbb; color: #526153; font: .8rem/1.45 var(--sans); }
.table-reference-hand { margin-bottom: 1rem; }
.table-reference-hand > summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; color: #294535; cursor: pointer; font: 700 .85rem/1.5 var(--sans); }
.table-reference-hand > summary::after { content: 'Hide tiles'; color: #526153; font-size: .75rem; text-decoration: underline; }
.table-reference-hand:not([open]) > summary::after { content: 'Show tiles'; }
.table-reference-columns { columns: 3 340px; column-gap: 1rem; }
.table-reference-category { margin: 0 0 1rem; break-inside: avoid; border: 1px solid #c5ba96; border-radius: 8px; overflow: hidden; background: #fffef9; }
.table-reference-dialog .table-reference-category > h3 { margin: 0; padding: .7rem .8rem; color: #294535; background: #e9eee2; font: 800 .9rem/1.3 var(--sans); }
.table-reference-line { padding: .75rem .8rem; border-top: 1px solid #ded9c9; }
.table-reference-line-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem .6rem; color: #435447; font: .75rem/1.4 var(--sans); }
.table-reference-line-heading > span { white-space: nowrap; }
.table-reference-dialog .card-line-pattern { gap: .15rem .25rem; margin: .45rem 0; font-size: clamp(1.1rem, 1.5vw, 1.4rem); line-height: 1.4; }
.table-reference-dialog .pattern-group { max-width: 100%; flex-wrap: wrap; overflow-wrap: anywhere; }
.table-reference-dialog .card-line-note { margin: 0; color: #4d5d50; font-size: .8rem; line-height: 1.5; overflow-wrap: anywhere; }
.table-reference-dialog .table-reference-key { font-size: .75rem; }
@media (max-width: 600px) {
  .table-reference-dialog .table-reference-hand .mini-game-tile { width: 36px; height: 52px; min-width: 36px; flex-basis: 36px; }
}
.table-play-editor { flex: 1 1 auto; min-height: 0; padding: 1rem 1.25rem; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scroll-padding-block: .75rem; }
.table-play-editor > p { margin: 0 0 1rem; color: #4b5e50; font: 400 .875rem/1.55 var(--sans); }
/* The live move editor keeps instructions and alternate actions in view while
   a large rack or list of public sets scrolls. Card-reference dialogs are separate. */
[data-table-play-editor] { display: flex; flex-direction: column; gap: .5rem; overflow: hidden; scrollbar-gutter: auto; }
.table-editor-tools { display: flex; flex: none; flex-wrap: wrap; gap: .4rem; }
.table-play-editor > .table-editor-instruction { flex: none; margin: 0; font-size: .8rem; line-height: 1.4; }
.table-editor-content { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scroll-padding-block: .5rem; }
.table-editor-content .table-exposure-preview { margin: 0 0 .65rem; }
.table-play-editor h3 { margin: 1.1rem 0 .65rem; color: #294f3c; font: 700 1rem/1.4 var(--sans); }
.table-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: .65rem .5rem; padding: .25rem .2rem .4rem; }
.table-pick-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: .55rem;
  min-width: 0;
  min-height: 44px;
  padding: .6rem .3rem .45rem;
  border: 2px solid #cbd2c2;
  border-radius: 8px;
  background: #f1f3e9;
  color: #294535;
  cursor: pointer;
}
.table-pick-tile > span:last-child { width: 100%; font: 700 .7rem/1.3 var(--sans); text-align: center; overflow-wrap: anywhere; }
.table-pick-tile:hover { border-color: #78926a; background: #eaf0df; }
.table-pick-tile[aria-pressed="true"] { border-color: #316546; background: #dbe9cf; box-shadow: inset 0 0 0 1px #316546; }
.table-pick-tile[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 3px; right: 3px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #28583a; color: white; font: 800 12px/1 var(--sans); }
.table-play-dialog .mini-game-tile,
.table-returned-tiles .mini-game-tile { display: inline-flex; width: 50px; height: 72px; min-width: 50px; flex: 0 0 50px; font-size: 1rem; }
.table-play-dialog .mini-game-tile > .tile-face,
.table-returned-tiles .mini-game-tile > .tile-face { width: 100%; height: 100%; box-shadow: inset 1px 1px 0 white, 0 3px 0 #7ea58d; }
.table-play-dialog .mini-game-tile .tile-corner,
.table-returned-tiles .mini-game-tile .tile-corner { top: 4px; left: 4px; color: #111; background: #fffaf0f2; padding: 1px 2px; border-radius: 2px; font: 900 11px/1 var(--sans); }
.table-exposure-preview { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .4rem; min-height: 88px; margin: .75rem 0 1rem; padding: .65rem .75rem .85rem; border: 1px solid #c5ba96; border-radius: 8px; background: #f5efd9; }
.table-exposure-preview > span:not(.mini-game-tile) { max-width: 95px; color: #62552f; font: 700 .75rem/1.4 var(--sans); }
.table-exposure-preview > span.table-called-preview { display: inline-flex; flex: 0 0 auto; align-items: center; gap: .4rem; max-width: none; padding-left: .5rem; border-left: 1px solid #c5ba96; }
.table-exchange-targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: .65rem; }
.table-exchange-targets > button { display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; min-width: 0; min-height: 44px; padding: .75rem; border: 2px solid #bdcbb5; border-radius: 8px; background: #f5f6ed; color: #234c35; text-align: left; cursor: pointer; }
.table-exchange-targets > button strong { font: 700 .8rem/1.4 var(--sans); overflow-wrap: anywhere; }
.table-exchange-targets > button > span { display: flex; flex-wrap: wrap; gap: .4rem; padding-bottom: 4px; }
.table-exchange-targets > button:hover { border-color: #6c8b59; background: #eaf0df; }
.table-exchange-targets > button[aria-pressed="true"] { border-color: #316546; background: #dbe9cf; box-shadow: inset 0 0 0 1px #316546; }
.table-exchange-targets > button[aria-pressed="true"] strong::before { content: "✓ "; }
.table-exchange-targets > p { margin: 0; padding: .85rem; border: 1px solid #cbd2c1; border-radius: 6px; color: #53634f; background: #f1f4e8; font: .875rem/1.5 var(--sans); }
.table-play-editor .table-commit-note { margin: 1rem 0 0; padding: .75rem .85rem; border-left: 3px solid #b28c48; border-radius: 0 5px 5px 0; background: #f4efdE; color: #66532f; font: .8rem/1.55 var(--sans); }
.table-play-editor > .table-commit-note { flex: none; margin: 0; padding: .45rem .6rem; font-size: .75rem; line-height: 1.35; }
/* Ordinary move editors fit a complete rack before growing into a scrollable
   list. Tile pictures are smaller; their selection targets remain at least 44px. */
[data-table-play-dialog] { max-height: calc(100dvh - 16px); }
[data-table-play-dialog] > header, [data-table-play-dialog] > footer { padding: .5rem .75rem; }
[data-table-play-dialog] > header .game-kicker { display: none; }
[data-table-play-dialog] h2 { font-size: 1.35rem; }
[data-table-play-editor] { padding: .5rem .75rem; gap: .4rem; }
.table-editor-content .table-picker-grid { grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 4px; padding: 3px 0; }
.table-editor-content .table-pick-tile { gap: 3px; padding: 4px 2px; border-radius: 5px; }
.table-editor-content .table-pick-tile > span:last-child { min-height: 2.2em; font-size: .65rem; line-height: 1.1; }
.table-editor-content .mini-game-tile { width: 32px; min-width: 32px; height: 46px; flex-basis: 32px; }
.table-editor-content .mini-game-tile .tile-corner { top: 2px; left: 2px; font-size: 10px; padding: 0 1px; }
.table-editor-content .mini-game-tile .tile-face > small { font-size: 5px; }
.table-editor-content .table-exposure-preview { min-height: 0; padding: .35rem .5rem; margin-bottom: .4rem; gap: 4px; }
.table-editor-content .table-exchange-targets { gap: .35rem; }
.table-editor-content .table-exchange-targets > button { flex-direction: row; align-items: center; justify-content: space-between; gap: .4rem; padding: .35rem .5rem; }
.table-editor-content .table-exchange-targets > button > span { flex: none; gap: 3px; padding-bottom: 2px; }
.table-editor-content > h3 { margin: .45rem 0 .25rem; font-size: .85rem; }
.table-play-message { flex: 0 0 auto; max-height: 18dvh; overflow-y: auto; margin: 0; padding: .7rem 1.25rem; border-top: 1px solid #c7947a; background: #fff0e5; color: #843d25; font: 700 .8rem/1.5 var(--sans); }
.table-play-message[hidden], .table-pass-return[hidden] { display: none !important; }
.table-pass-return { margin: .5rem 0; padding: .75rem 1rem; border: 1px solid #c49d68; border-radius: 8px; color: #634b2f; background: #fff4df; font: .8rem/1.5 var(--sans); }
.table-pass-return > strong { display: block; font-size: .85rem; }
.table-pass-return > p { margin: .4rem 0 0; }
.table-returned-tiles { display: flex; flex-wrap: wrap; gap: .45rem; padding: .5rem 0; }
/* A returned pass is feedback over the table, never an extra row that pushes
   the pass controls out of their fixed decision area. */
.is-playing .table-pass-return { position: fixed; z-index: 19; left: 50%; bottom: calc(var(--dock-height) + 8px); transform: translateX(-50%); width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 80px); overflow: auto; box-shadow: 0 8px 24px #052a2355; }

@media screen and (max-width: 700px), screen and (max-width: 1100px) and (max-height: 500px) {
  .table-pass-return { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 2px 8px; margin: .25rem 0; padding: .4rem .5rem; border-radius: 6px; line-height: 1.35; }
  .table-pass-return > strong { grid-column: 2; min-width: 0; font-size: .8rem; overflow-wrap: anywhere; }
  .table-pass-return > p { grid-column: 2; min-width: 0; margin: 0; overflow-wrap: anywhere; }
  .table-returned-tiles { grid-column: 1; grid-row: 1 / span 2; align-self: center; gap: 4px; max-width: 98px; padding: 0 0 3px; }
  .table-pass-return .table-returned-tiles .mini-game-tile { width: 30px; height: 44px; min-width: 30px; flex: 0 0 30px; font-size: .75rem; }
}

/* The table can continue after a dead hand. */
.table-dead-notice {
  display: flex;
  align-items: center;
  gap: clamp(.8rem, 2vw, 1.4rem);
  min-width: 0;
  padding: 1rem 1.2rem;
  border: 1px solid #bca778;
  border-radius: 12px;
  background: #183f36;
  color: #fff8e6;
  box-shadow: 0 4px 15px #17382a1a;
}
.table-dead-notice[hidden] { display: none !important; }
.table-dead-notice .table-skeleton {
  display: block;
  flex: 0 0 clamp(76px, 9vw, 112px);
  width: clamp(76px, 9vw, 112px);
  height: auto;
  margin: 0;
}
.table-dead-copy { flex: 1 1 auto; min-width: 0; }
.table-dead-notice .table-dead-eyebrow {
  margin: 0 0 .25rem;
  color: #e9d2a0;
  font: 800 .65rem/1.5 var(--sans);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.table-dead-notice h3 {
  margin: 0;
  color: #fff5dc;
  font: 500 clamp(1.45rem, 2.3vw, 2rem)/1.15 var(--serif);
  letter-spacing: -.015em;
}
.table-dead-notice p:not(.table-dead-eyebrow) {
  margin: .5rem 0 0;
  max-width: 65ch;
  color: #e7eadd;
  font: 400 .85rem/1.55 var(--sans);
  overflow-wrap: anywhere;
}
.table-dead-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.table-dead-notice .table-dead-actions .game-button {
  min-height: 44px;
  margin: 0;
  padding: .55rem .85rem;
  border: 1px solid #cfbb8b;
  border-radius: 6px;
  background: #f5e8c8;
  color: #193f32;
  font: 700 .8rem/1.3 var(--sans);
  cursor: pointer;
}
.table-dead-notice .table-dead-actions .game-button:hover { background: #fff5da; }
.table-dead-notice .table-dead-actions .game-button:focus-visible { outline: 3px solid #fff7de; outline-offset: 3px; }
.table-play-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .5rem;
  border: 1px solid #bca778;
  border-radius: 4px;
  color: inherit;
  font: 700 .7rem/1.35 var(--sans);
}
@media screen and (max-width: 480px) {
  .table-play-dialog { width: calc(100vw - 16px); border-radius: 10px; }
  .table-play-dialog > header, .table-play-dialog > footer { gap: .5rem; padding: .65rem .75rem; }
  .table-play-dialog > footer .game-button { flex: 1 1 0; }
  .table-play-dialog .game-button { padding: .55rem .65rem; font-size: .8rem; }
  .table-play-editor { padding: .75rem; }
  .table-play-message { padding: .6rem .75rem; }
  .table-picker-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: .5rem .35rem; }
  .table-exposure-preview { padding-inline: .5rem; }
  .table-exchange-targets > button { padding: .6rem; }
  .table-play-setting > p { margin-left: 0; }
  .table-dead-notice { align-items: flex-start; gap: .6rem; padding: .8rem; }
  .table-dead-notice .table-skeleton { flex-basis: 64px; width: 64px; margin-top: .3rem; }
  .table-dead-notice .table-dead-eyebrow { font-size: .6rem; letter-spacing: .04em; }
  .table-dead-notice p:not(.table-dead-eyebrow) { font-size: .8rem; }
  .table-dead-actions .game-button { flex: 1 1 auto; }
  [data-table-play-editor] { padding: .4rem; }
  .table-editor-content .table-picker-grid { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 3px; }
  .table-editor-content .table-pick-tile > span:last-child { font-size: .6rem; }
}
@media screen and (max-height: 540px) {
  .table-play-dialog > header, .table-play-dialog > footer { padding-block: .45rem; }
  .table-play-dialog > header .game-kicker { display: none; }
  .table-play-dialog h2 { font-size: 1.3rem; }
  .table-play-editor { padding-block: .65rem; }
  .table-dead-notice { padding-block: .6rem; }
  .table-dead-notice .table-skeleton { width: 62px; flex-basis: 62px; }
  .table-dead-notice h3 { font-size: 1.4rem; }
}
@media (forced-colors: active) {
  .table-pick-tile[aria-pressed="true"], .table-exchange-targets > button[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: -4px; }
}
@media print { .table-dead-notice, .table-play-mode-badge, .table-play-dialog, .table-pass-return { display: none !important; } }
.table-play-unavailable { opacity: .55; }
.table-play-training-note { padding: .8rem; border-left: 3px solid #bca778; background: #f6f0df; line-height: 1.5; }
.table-play-training-note[hidden] { display: none !important; }
.table-play-dead-dialog { width: min(680px, calc(100% - 24px)); max-height: 88dvh; margin: auto; padding: 0; border: 1px solid #bca778; border-radius: 12px; background: #183f36; overflow: auto; box-shadow: 0 24px 80px #001b17a0; }
.table-play-dead-dialog::backdrop { background: #061d19a8; }
.table-play-dead-dialog .table-dead-notice { border: 0; padding: 1.3rem; }
.table-play-dead-dialog:not([open]) { display: none; }

@media print { .table-play-dead-dialog { display: none !important; } }

/* Table Play: fixed landing positions, individual tiles, no automatic sorting. */
.is-playing .loose-discard-pile > .loose-discard-scroll {
  display: block; position: relative; overflow-x: hidden; overflow-y: auto; padding: 0;
  scrollbar-gutter: stable; overscroll-behavior: contain; scroll-snap-type: none;
  height: 170px; max-height: none;
}
.is-playing .loose-discard-surface { position: relative; width: 100%; min-height: 80px; }
.is-playing .loose-discard {
  position: absolute; display: grid; place-items: center;
  min-width: 44px; width: var(--discard-tile-width); min-height: 44px;
  height: calc(var(--discard-tile-width) * 1.45 + 6px); padding: 0;
  border: 0; border-radius: 5px; background: transparent; cursor: zoom-in;
  transform: translate(-50%,-50%);
}
/* Rotate the face while keeping the inspection target within its landing row. */
.is-playing .loose-discard .mini-game-tile { margin: 0; flex: none; transform: rotate(var(--landing-angle, 0deg)); }
.is-playing .loose-discard .tile-corner { top: 3px; left: 3px; color: #111; font-size: max(10px, calc(var(--discard-tile-width) * .24)); }
.is-playing .loose-discard:hover, .is-playing .loose-discard:focus-visible, .is-playing .loose-discard[aria-expanded="true"] { outline: 2px solid #ffe4ab; outline-offset: 3px; z-index: 2; }
.is-playing .loose-discard-scroll:focus-visible { outline: 2px solid #ffe4ab; outline-offset: -2px; }
