/* Right seat: live message, then the table controls. */
#gameTable #turnRail {
  gap:clamp(4px,.9vh,9px);
  container-type:inline-size;
}
#gameTable #turnRail #turnInfo {
  box-sizing:border-box;
  position:relative;
  display:grid;
  place-items:center;
  min-width:0;
  border-radius:14px;
  padding:12px 10px;
  color:#fff2cf;
  background:linear-gradient(90deg,#10102b70,#100d2bba 50%,#15152b80),
    url("season-result/space.webp") center / cover,#0c1027;
}
#gameTable #turnRail #turnInfo::after,
#gameTable #turnRail #fullBoardTools::after {
  content:"";
  position:absolute;
  inset:0;
  border:solid transparent;
  border-width:21px 15px;
  border-image:url("crystal-rim-aquamarine.webp") 156 82 / 21px 15px stretch;
  pointer-events:none;
}
#gameTable #turnRail .turnMessage {width:100%;min-width:0;}
#gameTable #turnRail #turnInfo #status {
  box-sizing:border-box;
  display:grid;
  align-content:center;
  height:auto;
  min-height:2.6em;
  max-height:6.5em;
  padding:1px 5px;
  border:0;
  border-radius:0;
  color:inherit;
  background:none;
  box-shadow:none;
  font:650 clamp(13px,5.3cqw,17px)/1.32 system-ui,sans-serif;
  text-shadow:0 1px 3px #090615;
  white-space:normal;
  overflow:auto;
}
#gameTable #turnRail #turnInfo.localWin {
  min-height:clamp(90px,min(60cqw,20.5dvh,calc(100cqh - 87px)),174px);
  padding:clamp(25px,9cqw,32px) 7% 9px;
  background:
    radial-gradient(ellipse at 50% 59%,#120c2ce8 22%,#25104a55 58%,transparent 77%),
    url("season-result/space.webp") center / cover,#150d38;
}
#gameTable #turnRail #turnInfo.localWin::before {
  content:"";
  position:absolute;
  top:11%;left:40%;width:20%;height:22%;
  background:url("club-boutique/crown.webp") center / contain no-repeat;
}
#gameTable #turnRail .localWin .turnMessage {
  position:relative;
  box-sizing:border-box;
  width:100%;
  margin:8px 0 0;
  padding:5px 13%;
  background:
    linear-gradient(90deg,transparent 9%,#d7993f 26%,#fff0ae 50%,#d7993f 74%,transparent 91%) top / 96% 1px no-repeat,
    linear-gradient(90deg,transparent 9%,#d7993f 26%,#fff0ae 50%,#d7993f 74%,transparent 91%) bottom / 96% 1px no-repeat;
}
#gameTable #turnRail .localWin .turnMessage::before,
#gameTable #turnRail .localWin .turnMessage::after {
  content:"";position:absolute;inset:0 auto 0 -2%;width:18%;
  background:url("crystal-leaves.webp") left center / contain no-repeat;pointer-events:none;
}
#gameTable #turnRail .localWin .turnMessage::after {left:auto;right:-2%;transform:scaleX(-1);}
#gameTable #turnRail #turnInfo.localWin #status {
  min-height:2.2em;max-height:none;overflow:visible;
  padding:0;
  color:#fff0b0;
  font:700 clamp(16px,8.35cqw,28px)/1.08 Georgia,"Times New Roman",serif;
  text-wrap:balance;
  text-shadow:0 1px #72400a,0 0 5px #c4741f,0 2px 6px #160716;
}
html body #gameTable #turnRail #turnControls {
  box-sizing:border-box;
  gap:5px !important;
  padding:0 !important;
  border:0;border-image:none;border-radius:0;background:none;box-shadow:none;
}
body.sideTable.flankPlayers #gameTable #railGroup {container-type:size;}
#gameTable #turnRail #fullBoardTools {
  position:relative;
  box-sizing:border-box;
  padding:9px 7px;
  border-radius:12px;
  background:linear-gradient(90deg,#0e122c70,#13103596),url("season-result/space.webp") center bottom / cover,#100d2b;
}
#gameTable #turnRail #fullBoardTools::after {border-image-width:16px 13px;}
#gameTable #turnRail #turnControls .actions:not(:has(button:not([hidden]))) {display:none !important;}
#gameTable #turnRail #turnControls #fullBoardTools {
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  gap:clamp(2px,1.3cqw,5px);
  --tool-size:clamp(28px,13cqw,40px);
}
#gameTable #turnRail #fullBoardTools :is(#fsGear,#fsBtn,#fbLog,#fbChat,#diceSizeQuick) {
  position:relative !important;inset:auto !important;
  display:inline-flex !important;align-items:center;justify-content:center;
  box-sizing:border-box;flex:0 0 auto;
  width:var(--tool-size) !important;height:var(--tool-size) !important;min-height:0;
  padding:0;margin:0;
}
#gameTable #turnRail #fullBoardTools #diceSizeQuick {
  width:auto !important;max-width:100%;
  padding:0 clamp(4px,1.8cqw,8px);
  font-size:clamp(11px,4.6cqw,14px);
}
#gameTable #turnRail #fullBoardTools :is(#fbLog,#fbChat) svg {width:63%;height:63%;max-width:24px;}
body.portraitMatch #gameTable #tableToolbar {justify-content:flex-end;}
@media (orientation:landscape) and (max-height:530px) {
  #gameTable #turnRail #turnInfo {padding:7px;}
  #gameTable #turnRail #turnInfo.localWin {min-height:78px;padding:21px 5% 7px;}
  #gameTable #turnRail .localWin .turnMessage {margin:3px 0 0;padding-block:2px;}
  #gameTable #turnRail #fullBoardTools {padding:5px;}
}

/* One column for Modes and Dice, with the other header actions alongside. */
html body #gameHeader .hdrBtns {
  display: grid;
  grid-template-columns: max-content minmax(0, max-content);
  justify-content: end;
  align-items: stretch;
  gap: 4px 5px;
}
#gameHeader :is(.tableMenuPrimary, .tableMenuSecondary) {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}
#headerDiceSlot { display: flex; }
#gameHeader #diceSizeQuick, #gameTable #phoneTools #diceSizeQuick {
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; gap: .35em; min-width: 0; width: 100%; margin: 0;
}
#gameHeader #diceSizeQuick::after, #gameTable #phoneTools #diceSizeQuick::after { content: none; }
#gameTable #tableToolbar #phoneTools:has(> #diceSizeQuick) {
  display: flex !important;
  order: 0;
}
#gameTable #tableToolbar #phoneTools #diceSizeQuick {
  border-radius: 50%; width: 36px !important; height:36px !important; padding: 0;
}
#phoneTools #diceSizeQuick span {
  position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap;
}
#phoneTools #diceSizeQuick .diceSample { --side: 19px; }

/* Allocate the readout and tools before laying out variable match actions. */
#gameTable #turnRail {
  --readout-height: clamp(72px, 10.2dvh, 90px);
  --rail-gap: 4px;
  gap: var(--rail-gap);
}
#gameTable #turnRail #turnInfo,
#gameTable #turnRail #turnInfo.localWin {
  box-sizing: border-box;
  height: var(--readout-height);
  min-height: 0;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  padding: 8px 11px;
}
#gameTable #turnRail #turnInfo .turnMessage {
  display: grid; width: 100%; min-height: 0; height: 100%; align-items: stretch;
}
#gameTable #turnRail #turnInfo #status {
  display: block; min-height: 0; max-height: none; height: 100%;
  align-content: safe center; overflow: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #72749f transparent;
}
#gameTable #turnRail #turnInfo.localWin { padding: 20px 8% 8px; }
#gameTable #turnRail #turnInfo.localWin::before { top: 4%; height: 22%; }
#gameTable #turnRail .localWin .turnMessage { margin: 0; padding-block: 1px; }
#gameTable #turnRail #turnInfo.localWin #status { font-size:clamp(15px,7cqw,22px); }
#gameTable #turnRail #fullBoardTools {
  --tool-size: clamp(30px, 12cqw, 38px);
  padding: 5px 8px;
  gap: clamp(5px, 2cqw, 9px);
  flex-wrap: nowrap;
}
#gameTable #turnRail #turnControls #fullBoardTools {
  flex-wrap: nowrap;
  gap: clamp(5px, 2cqw, 9px);
}
#gameTable #turnRail #turnControls {
  display: grid !important;
  grid-template: auto minmax(0,1fr) / minmax(0,1fr);
  align-content: start; min-height: 0; gap: var(--rail-gap) !important;
}
#gameTable #turnSecondary {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  gap: var(--rail-gap); padding: 2px 3px 4px;
}
#gameTable #turnSecondary > * { flex-shrink: 0; }
#gameTable #turnSecondary > aside.sidebar { position: static !important; width: 100%; max-width: 100%; order: 4; }
#gameTable #turnRail #turnSecondary #tblBtns {
  display: grid !important; grid-template-columns: repeat(2, minmax(0,1fr));
  align-items: stretch !important; gap: 4px !important;
}
#gameTable #turnSecondary #btnLeave { grid-area: 1/1; }
#gameTable #turnSecondary [data-game-exit] { grid-area: 1/2; }
#gameTable #turnSecondary #btnNew { grid-area: 2/1; }
#gameTable #turnSecondary #btnResign { grid-area: 2/2; }
html body #gameTable #turnRail #tblBtns > button:not([hidden]) {
  width: 100% !important; min-height: 30px !important;
  margin: 0; padding: 4px !important;
  font-size: clamp(11px,4.5cqw,14px) !important; line-height: 1.15;
}
html body #gameTable #turnRail #tblBtns > :is([hidden],#btnResign.off) { display:none !important; }
body.sideTable.flankPlayers #gameTable #railGroup {
  overflow: clip; align-self: stretch;
}
body.sideTable.flankPlayers #gameTable #turnRail {
  height: 100%; min-height: 0; max-height: none;
  grid-template: var(--readout-height) minmax(0,1fr) / minmax(0,1fr);
}
body.sideTable.flankPlayers #gameTable #turnSecondary {
  overflow: hidden auto; overscroll-behavior: contain; scrollbar-width: thin;
}
@media (orientation:landscape) and (max-height:530px) {
  #gameTable #turnRail { --readout-height: 54px; --rail-gap: 3px; }
  #gameTable #turnRail #turnInfo { padding: 5px 7px; }
  #gameTable #turnRail #turnInfo.localWin { padding: 12px 6% 5px; }
  #gameTable #turnRail #fullBoardTools { padding-block: 3px; }
  #gameTable #tableToolbar { gap: 3px; }
}
/* Keep both action rows reachable when the cards and header take up more of a
   short desktop window. The table can extend into normal page scrolling. */
@media (min-height: 531px) {
  body.sideTable.flankPlayers #gameTable {
    --rail-floor: calc(clamp(72px, 10.2dvh, 90px) + 146px);
    min-height: min-content !important;
    grid-template-rows: auto auto minmax(var(--rail-floor), 1fr) !important;
  }
}
#gameTable #turnSecondary #tblBtns { order: 0; }
#gameTable #turnSecondary .replayBar { order: 1; }
