/* Each table has one viewport. The rack and heading take their natural height;
   the board uses the smaller dimension of the space left over. */
body[data-screen] {
  display: flex;
  flex-direction: column;
  height: var(--app-height,100vh);
  height: 100dvh;
  min-height: 0;
}
body[data-screen] > .mast, #connection {flex: none;}
body:is([data-screen="game"],[data-screen="lobby"]) > .mast {display: none;}
body:is([data-screen="game"],[data-screen="lobby"]) main.wrap {
  --gutter: clamp(6px, 1.5vw, 24px);
  width: min(100%, 1800px, calc(100dvh + 560px));
  padding: max(6px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
           max(6px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(4px, .9vh, 12px);
}
.table-heading, .table-actions, .board-tools, .table-boardbar, .side-heading {
  display: flex;
  align-items: center;
}
.table-heading {
  min-width: 0;
  gap: clamp(6px, 1.5vw, 18px);
  padding: 0 2px clamp(3px, .7vh, 8px);
  border-bottom: 1px solid var(--line);
}
.table-home {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  text-decoration: none;
}
.table-title {min-width: 0; flex: 1;}
.table-title h1, .table-context {white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.table-title h1 {margin: 0; font: 700 clamp(1.28rem, 2.25vw, 2.15rem)/1.13 var(--serif);}
.table-context {font: 600 .81rem/1.3 var(--sans); color: var(--sub);}
.table-actions {gap: 6px; flex: none;}
.table-actions button {min-height: 44px;}
.table-play {
  display: grid;
  grid-template: "scores" auto "board" minmax(0, 1fr) "dock" auto / minmax(0, 1fr);
  gap: clamp(3px, .7vh, 9px);
  min-width: 0;
  min-height: 0;
}
.table-side {display: contents;}
.board-pane {
  grid-area: board;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  min-width: 0;
  min-height: 0;
  container: boardpane / inline-size;
}
.table-boardbar {justify-content: space-between; gap: 3px; padding-inline: 2px; min-width: 0;}
.table-boardbar .bag {font-size: .86rem; gap: 4px;}
.table-boardbar .ico {width: 18px; height: 18px;}
.board-tools {gap: 2px;}
.board-tools button {min-width: 44px; min-height: 44px; padding: 4px 8px; font-size: .87rem; gap: 5px;}
.board-well {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  container-type: size;
}
.board-well > .board-shell {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid #698577;
  border-radius: 7px;
  padding: clamp(2px, .55cqw, 7px);
  background: #456452;
  box-shadow: 0 2px 6px #112d201c;
  container-type: inline-size;
}
.board-well > .board-shell:not(.focused) {
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  max-width: 100%;
  margin: 0;
}
.board-well > .board-shell.focused {width: 100%; height: 100%; aspect-ratio: auto;}
.board-well .board-shell .viewport {width: 100%; height: 100%; max-width: 100%; border-radius: 2px;}
.board-shell:not(.focused) .viewport {overflow: hidden;}
.board-well #board {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 1;
  grid-template-columns: minmax(11px,.55fr) repeat(15,minmax(0,1fr));
  grid-template-rows: minmax(11px,.55fr) repeat(15,minmax(0,1fr));
}
.board-well .focused #board {width: max(735px, 142cqw); height: auto; min-height: 0; aspect-ratio: 1;}
.board-well .axis {font-size: clamp(8px, 2.05cqw, 15px); line-height: 1;}
.board-well .sq {font-size: clamp(6.5px, 2.13cqw, 15px);}
.board-well .sq.tile {font-size: clamp(10px, 4.05cqw, 45px);}
.board-well .focused .sq.tile {font-size: clamp(25px,5.7cqw,58px);}
.board-well .focused .axis, .board-well .focused .sq:not(.tile) {font-size: clamp(11px,2.5cqw,16px);}
.board-well .sq.tile small {font-size: max(5px,.34em);}
.board-well .sq.cursor {box-shadow: inset 0 0 0 2px #184b40;}
.board-well .sq:focus-visible {outline-offset: -2px; z-index: 2;}
.compact-scores {grid-area: scores; display: flex; min-width: 0; align-items: stretch; gap: 4px;}
.compact-scores > .tertiary {font-size: .83rem; padding: 3px 6px; gap: 4px;}
.score-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0,1fr);
  gap: 3px;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  text-align: left;
}
.score-chip {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 6px;
  min-width: 0;
  font-size: .82rem;
}
.score-chip > span {overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.score-chip b {font-size: 1rem; line-height: 1; font-variant-numeric: tabular-nums;}
.score-chip.active-seat {box-shadow: inset 0 -3px currentColor;}
.table-play #rackdock, .table-play #rackdock:not(:empty) {grid-area: dock; position: static; padding: 0; background: transparent; min-width: 0;}
.table-play #rackdock:empty {display: none;}
.table-play .rackbox {padding: 4px 7px 6px; margin: 0; border-radius: 10px;}
.table-play .racktop {gap: 3px;}
.table-play .racktop h2 {font-size: clamp(1.1rem,2.1vw,1.5rem); line-height: 1.1;}
.table-play .racktop > div {flex-wrap: nowrap;}
.table-play .racktop .tertiary {min-height: 44px; padding: 3px 8px; font-size: .88rem;}
.table-play .rack {max-width: 100%; gap: 3px; margin: 1px 0 3px;}
.table-play .racktile {width: 100%; height: clamp(44px,6.1vh,64px); min-height: 44px; max-height: none; aspect-ratio: auto;}
.table-play .draftline {min-height: 1.3em; margin: 3px 1px; line-height: 1.3; font-size: .84rem; overflow-wrap: anywhere;}
.table-play .rackactions {gap: 5px;}
.table-play .rackactions button, .finish-actions button {min-height: 44px; padding: 5px 12px;}
.table-play .rackactions .primary {min-width: 0; flex: 1; max-width: 170px;}
.side-scores, .side-turns, .side-links, .last-play {display: none;}
.finish-actions {grid-area: dock; display: flex; gap: 6px; align-items: stretch;}
.finish-actions button {flex: 1;}
.side-heading {justify-content: space-between; gap: 8px;}
.side-heading h2 {margin: 0; font-size: 1.5rem;}
.side-heading .tertiary {min-height: 42px; padding: 4px 6px;}
.last-play {background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; text-align: left; align-items: center; min-width: 0; gap: 9px; padding: 6px 10px; min-height: 40px;}
.last-play span {color: var(--sub); font-size: .86rem; white-space: nowrap;}
.last-play strong {overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;}
.last-play b {font-variant-numeric: tabular-nums;}
@media (min-height:725px) {
  .table-play {grid-template-areas: "scores" "board" "latest" "dock";grid-template-rows: auto minmax(0,1fr) auto auto;}
  .last-play {display: flex; grid-area: latest;}
}
@media (min-width:740px) and (min-aspect-ratio:1/1), (min-width:525px) and (max-height:560px) and (orientation:landscape) {
  .table-play {grid-template: "board side" minmax(0,1fr) / minmax(0,1fr) clamp(328px,32vw,470px); column-gap: clamp(7px,1.6vw,28px);}
  .table-side {grid-area: side; display: flex; flex-direction: column; gap: clamp(5px,1.2vh,15px); min-height: 0; min-width: 0; justify-content: center;}
  .table-play .rackbox {padding: 5px 8px 8px;}
  .table-play .rack {gap: 3px;}
  .side-links {display: flex; justify-content: space-between;}
  .side-links button {font-size: .88rem; padding: 4px 6px;}
  .table-play .last-play {display: flex;}
}
@media (min-width:740px) and (min-aspect-ratio:1/1) and (min-height:640px) {
  .compact-scores {display: none;}
  .table-side {justify-content: flex-start; padding-block: clamp(6px,3.5vh,42px);}
  .table-side .card {padding: clamp(9px,1.2vh,18px) clamp(12px,1.3vw,24px);}
  .side-scores, .side-turns {display: block;}
  .table-play .last-play {display: none;}
  .side-scores .scores li {padding: 5px 0;}
  .side-scores .scores strong {line-height: 1.2;}
  .side-scores .score {font-size: clamp(1.35rem,2.5vw,2rem);}
  .side-turns .history li {padding: 4px 0;}
  .side-turns .history li:nth-child(n+2) {display: none;}
  .side-links {justify-content: flex-end;}
  .side-links [data-act="turns"] {display: none;}
  .shared .side-turns .history li {display: flex;}
  .shared .table-side {justify-content: center;}
}
@media (min-width:740px) and (min-aspect-ratio:1/1) and (min-height:830px) {
  .side-turns .history li:nth-child(n+2) {display: flex;}
  .side-scores .scores li {padding: 9px 0;}
}
@media (min-width:1200px) and (min-height:800px) {
  .shared .scores strong, .shared .history strong {font-size: clamp(1.05rem,1.3vw,1.5rem);}
  .shared .side-heading h2 {font-size: 1.85rem;}
  .shared .scores small, .shared .history small {font-size: .96rem;}
}
@media (max-width:700px) {
  .table-home, .table-heading .brandmark {width: 31px; height: 32px;}
  .table-heading {gap: 7px;}
  .table-context {font-size: .73rem;}
  .table-actions button {padding: 5px 8px;}
  .table-options .btnlabel {display: none;}
  .table-options {width: 44px;}
  .table-actions .codebtn {letter-spacing: .07em;}
  .table-actions .codebtn .ico {display: none;}
  .score-chip {flex-direction: column; align-items: flex-start; justify-content: center; line-height: 1.1; gap: 2px; padding: 3px 5px;}
  .score-chip > span {max-width: 100%;}
}
@container boardpane (max-width:430px) {
  .board-tools button {padding-inline: 5px;}
  .board-tools [data-act="full"] {display: none;}
}
@container boardpane (max-width:260px) {
  .board-tools [data-act="pick-square"] .btnlabel,.board-tools [data-act="replay"] .btnlabel, .board-tools [data-act="zoom"] span, .bag-label {display: none;}
  .board-tools [data-act="zoom"] {font-size: 0;}
  .board-tools {gap: 0;}
}
@media (max-height:560px) and (orientation:landscape) {
  .table-side {gap: 4px;}
  .table-play .last-play, .table-play .side-links {display: none;}
  .table-play .rackbox {padding: 2px 3px 4px;}
  .table-play .rack {gap: 2px;}
  .table-actions .codebtn, .table-options {padding-block: 3px;}
}
@media (max-width:355px) {
  body:is([data-screen="game"],[data-screen="lobby"]) main.wrap {--gutter: 0px;}
  .table-heading,.table-boardbar,.compact-scores {padding-inline: 4px;}
  .table-play .rackbox {padding-inline: 2px;}
  .table-play .rack {gap: 1px;}
}
@media (max-height:390px) {
  .table-heading {padding-bottom: 0;}
  .table-context {font-size: .72rem;}
  .table-title h1 {font-size: 1.28rem;}
}

/* Waiting rooms keep the invite, seats and launch controls together. */
body[data-screen="lobby"] main.wrap {max-width: 1040px;}
.waiting-room {
  align-self: center;
  display: grid;
  grid-template: "invite roster" minmax(0,1fr) "facts actions" auto / minmax(0,1fr) minmax(0,1fr);
  gap: clamp(7px,1.6vh,18px);
  align-items: stretch;
  min-width: 0;
}
.waiting-room .invite {grid-area: invite; flex-wrap: nowrap; padding: clamp(12px,2vw,30px); gap: 8px;}
.waiting-room .roomcode {font-size: clamp(2rem,4.6vw,4.1rem); line-height: 1.2;}
.waiting-room .eyebrow {margin: 0;}
.waiting-room .invite .hero-alt {margin-top: 7px;}
.qr-button {background: white; border: 0; padding: 0; border-radius: 7px; flex: none; line-height: 0; cursor: zoom-in;}
.waiting-room .qr {width: clamp(76px,12vw,140px);}
.waiting-roster {grid-area: roster; padding: clamp(8px,1.6vw,20px);}
.waiting-roster .secttop {margin-bottom: 3px;}
.waiting-roster h2 {font-size: clamp(1.15rem,2.2vw,1.8rem);}
.waiting-roster .scores li {padding: 5px 0;}
.waiting-roster .score {display: none;}
.waiting-actions {grid-area: actions; display: flex; justify-content: flex-end; gap: 6px; align-items: center;}
.waiting-facts {grid-area: facts; align-self: center; font-size: .87rem; color: var(--sub);}
@media (max-width:660px) and (orientation:portrait) {
  .waiting-room {grid-template: "invite" auto "roster" auto "facts" auto "actions" auto / minmax(0,1fr); padding-inline: 3px;}
  .waiting-room .invite {padding: 9px 14px;}
  .waiting-room .qr {width: clamp(75px,20vw,110px);}
  .waiting-roster .scores li {padding: 3px 0;}
  .waiting-actions > button {flex: 1;}
}
@media (max-height:560px) {
  .waiting-room {gap: 5px;}
  .waiting-roster .scores li {padding: 2px 0; gap: 6px;}
  .waiting-roster .scores li>div {display: flex; align-items: baseline; justify-content: space-between; gap: 5px;}
  .waiting-roster .scores strong {min-width: 0; line-height: 1.18;}
  .waiting-roster .scores li>div>small {flex: none;}
  .waiting-roster .avatar {width: 24px; height: 24px; font-size: .9rem;}
  .waiting-room .invite .hero-alt {margin-top: 2px;}
  .waiting-actions button {padding-inline: 9px;}
  .waiting-facts {font-size: .8rem;}
}

/* Secondary views have their own navigation. A keyboard or larger text can
   scroll a dialog's content while the game stays in place. */
dialog[open] {display: flex; flex-direction: column; overflow: hidden; max-height: min(calc(var(--dialog-height,100dvh) - 14px),810px);}
.dialoghead {flex: none; position: static; gap: 8px; min-width: 0;}
.dialoghead h2 {flex: 1; min-width: 0; line-height: 1.15;}
#dialogbody {overflow-y: auto; overscroll-behavior: contain; min-height: 0;}
#dialogerror {flex: none; margin: 0; padding: 5px 14px;}
.menu-grid {display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px;}
.menu-grid button {padding: 7px 8px; min-width: 0; line-height: 1.2;}
.game-admin {margin-bottom: 10px;}
.help-actions {margin-top: 6px;}
.sheet-tabs,.browsebar,.pager {display: flex; align-items: center; gap: 6px;}
.sheet-tabs {border-bottom: 1px solid var(--line);}
.sheet-tabs .tab {flex: 1; padding: 5px 8px;}
.detail-content .legendgrid {grid-template-columns: 1fr 1fr;gap: 12px;}
.final-scores {width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums;}
.final-scores th,.final-scores td {padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line);}
.final-scores th:first-child {text-align: left; overflow-wrap: anywhere;}
.final-scores thead th {font-size: .78rem; font-weight: 600; color: var(--sub);}
.final-reason {margin: 4px 0; color: var(--sub);}
.browsebar,.pager {justify-content: space-between;}
.browsebar .tabbar {margin: 0;}
.pager {margin-top: 6px; font-size: .86rem;}
.pager button {min-height: 44px; padding: 4px 10px;}
.directory-list .directoryrow {padding: 7px 0; border-bottom: 1px solid var(--line);}
.join-qr {display: grid; justify-items: center; gap: 10px;}
.join-qr img {width: min(230px,68vw,43dvh); height: auto;}
.pick-areas {display: grid; grid-template-columns: repeat(3,1fr); gap: 7px;}
.pick-area {flex-direction: column; gap: 2px; min-height: 56px; padding: 6px; line-height: 1.2;}
.pick-area span {font-size: .78rem; color: var(--sub);}
.pick-grid {display: grid;grid-template-columns: 22px repeat(5,minmax(44px,1fr)); grid-template-rows: 17px repeat(5,minmax(44px,1fr));gap: 3px;max-width: 355px;margin: auto;}
.pick-grid .sq {border-radius: 4px;min-height: 44px;font-size: .8rem;}
.pick-grid .sq.tile {font-size: 1.55rem;}
.pick-axis {text-align: center;align-self: center;font-size: .8rem;font-weight: 700;color: var(--sub);}
dialog[data-panel="picker"] {width: min(400px,calc(100vw - 16px));}
@media (max-height:550px) {
  .dialoghead {padding: 3px 9px;}
  .dialoghead h2 {font-size: 1.25rem;}
  #dialogbody {padding: 7px 12px;}
  .detail-content .history li,.detail-content .scores li {padding: 3px 0;}
  .detail-content .history li>div {display:flex;align-items:baseline;gap:8px;}
  .sheet-tabs .tab {min-height: 38px;}
  .pick-grid {gap: 2px;}
  .controlbody,form {gap: 6px;}
}

/* The parlor uses the same viewport budget as a table. On small screens its
   directory opens as a sheet, keeping the three play modes within reach. */
.compact-directory {display: none;}
body[data-screen="home"] main.wrap {
  display: grid;
  align-content: center;
  gap: clamp(8px,1.5vh,18px);
  flex: 1;
  min-height: 0;
  padding-block: max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-bottom));
}
body[data-screen="home"] .publicbox, body[data-screen="home"] .return {margin: 0;}
body[data-screen="home"] .hero {min-height: clamp(205px,31vh,360px);}
body[data-screen="home"] .hero-copy {padding-block: clamp(12px,3.4vh,45px);}
body[data-screen="home"] .publicbox {padding-block: clamp(12px,1.7vh,22px);}
body[data-screen="home"] .hero .actions {flex-wrap: wrap;}
@media (max-height:800px), (max-width:760px) {
  body[data-screen="home"] .publicbox {display: none;}
  body[data-screen="home"] .compact-directory {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 6px 12px;
  }
  .compact-directory h2 {margin: 0; font-size: clamp(1.1rem,3vw,1.5rem);}
  body[data-screen="home"] .return {padding: 6px 12px;}
}
@media (max-width:580px) {
  body[data-screen="home"] .hero-copy {padding: clamp(12px,2.7vh,26px) 15px;}
  body[data-screen="home"] .hero .actions {gap: 5px;}
  body[data-screen="home"] .hero .actions button {padding: 7px 10px;}
  body[data-screen="home"] .hero-art {bottom: 102px;}
}
@media (max-height:560px) and (orientation:landscape) and (min-width:525px) {
  body[data-screen="home"] .mast nav {height: 44px;}
  body[data-screen="home"] main.wrap {grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: 8px;}
  body[data-screen="home"] .hero {grid-area: 1/1/3/2; min-height: 0;}
  body[data-screen="home"] .hero-copy {width: 100%;padding: 12px;}
  body[data-screen="home"] .hero h1 {margin: 4px 0; font-size: clamp(2.1rem,5vw,3.3rem);}
  body[data-screen="home"] .hero-art {display: none;}
  body[data-screen="home"] .return,body[data-screen="home"] .compact-directory {grid-column: 2;align-items: center;justify-content: center;display: grid;gap: 3px;padding: 6px;}
  body[data-screen="home"] .herolink {margin-top: 2px;}
}
@media (min-width:740px) and (min-aspect-ratio:1/1) and (min-height:561px) {
  .table-play {grid-template-columns: minmax(0,1fr) clamp(346px,32vw,470px);}
}
.setup-step,.setup-names {display: grid; gap: 10px;}
.setup-actions {display: flex; gap: 7px;}
.setup-actions button {flex: 1;}
.setup-step .muted {margin: 0;}
.side-turns .history li>div {min-width: 0;}
.side-turns .history strong {display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.toast {pointer-events: none;}
body:is([data-screen="game"],[data-screen="lobby"]) .toast {top: max(5px,env(safe-area-inset-top)); bottom: auto;}
@media (min-width:740px) and (min-aspect-ratio:1/1) and (min-height:640px) and (max-height:795px) {
  .table-side {gap: 5px; padding-block: 3px;}
  .table-side .card {padding-block: 6px;}
  .side-scores .scores li {padding-block: 2px;}
}
@media (max-height:550px) {
  dialog[data-panel="create"],dialog[data-panel="join"],dialog[data-panel="blank"] {width: min(565px,calc(100% - 14px));}
  .setup-step,.setup-names {gap: 5px;}
  .setup-step .modepick span {min-height: 44px; padding: 4px 7px;}
  .setup-step legend {margin-bottom: 3px;}
}
@media (min-width:480px) and (max-height:550px) {
  .setup-names {grid-template-columns: repeat(2,minmax(0,1fr));}
  #joinform {grid-template-columns: repeat(2,minmax(0,1fr));align-items: end;}
  .alphabet {grid-template-columns: repeat(9,minmax(0,1fr));}
  .pick-grid {grid-template-rows: 14px repeat(5,44px);}
}

.small-status {display: none;}
@media (max-width:524px) and (max-height:580px) and (orientation:portrait) {
  .table-play {grid-template: "scores tools" auto "board board" minmax(0,1fr) "dock dock" auto / minmax(0,1fr) auto;}
  .board-pane {display: contents; container-type: normal;}
  .table-boardbar {grid-area: tools; padding: 0;}
  .board-well {grid-area: board;}
  .table-boardbar .bag,.board-tools [data-act="full"],.table-boardbar .btnlabel,.board-tools [data-act="zoom"] span,.compact-scores .tertiary .btnlabel {display: none;}
  .board-tools button,.compact-scores > .tertiary {width: 44px; min-width: 44px; padding: 0;}
  .compact-scores {gap: 0; padding-right: 0;}
  .score-chip {padding-inline: 4px;}
  body[data-screen="game"] .table-context {display: none;}
  .small-status {display: block;font-size: .73rem;line-height: 1.2;color: var(--sub);}
  .table-play .rackbox {
    display: grid; grid-template-columns: 44px auto 44px minmax(44px,.75fr) minmax(75px,1.2fr);
    grid-template-rows: auto auto auto;gap: 2px;
  }
  .table-play .racktop, .table-play .racktop>div, .table-play .rackactions {display: contents;}
  .table-play .rackbox h2 {position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);}
  .table-play .rack {grid-area: 1/1/2/-1; width: 100%; margin: 0;}
  .table-play .draftline {grid-area: 2/1/3/-1; margin: 0;}
  .rackbox [data-act="arrange"] {grid-area: 3/1;}
  .rackbox [data-act="direction"],.rackbox [data-act="shuffle"] {grid-area: 3/2;}
  .rackbox [data-act="undo"] {grid-area: 3/3;}
  .rackbox [data-act="more"] {grid-area: 3/4;}
  .rackbox [data-act="play"] {grid-area: 3/5;}
  .table-play .rackactions button,.table-play .racktop button {padding-inline: 5px;max-width: none;}
  .rackbox [data-act="arrange"] .btnlabel,.rackbox [data-act="undo"] .btnlabel {display: none;}
}
@media (min-width:740px) and (min-aspect-ratio:1/1) and (min-height:640px) and (max-height:690px) {
  .side-links {display: none;}
  .side-turns .side-heading .tertiary {min-height: 44px;}
}
@media (max-width:355px) {
  body[data-screen="home"] .hero {display: grid;}
  body[data-screen="home"] .hero-copy {width: 100%;padding: 10px;}
  body[data-screen="home"] .hero h1 {font-size: 2.65rem; margin: 5px 0;}
  body[data-screen="home"] .hero .actions {display: grid;grid-template-columns: 1fr 1fr;}
  body[data-screen="home"] .hero .actions button {min-width: 0; padding: 5px 6px; line-height: 1.1;}
  body[data-screen="home"] .hero-art {bottom: 108px;}
  body[data-screen="home"] .return button {white-space: nowrap;padding-inline: 7px;}
}
.settings-tabs {display: flex; gap: 3px; border-bottom: 1px solid var(--line);}
.settings-tabs .tab {flex: 1;min-height: 44px;padding: 5px 6px;}
.settings-panel {display: grid;gap: 8px;align-items: end;}
.rules-fields,.computer-fields {grid-template-columns: repeat(2,minmax(0,1fr));}
.rules-fields label:last-child {grid-column: 1/-1;}
.settings-panel .tick {min-height: 44px;margin: 0;}
#dialogstatus {flex: none; margin: 0; padding: 5px 14px; font-weight: 600; color: var(--brand); background: var(--pale);}
@media (min-width:480px) and (max-height:550px) {
  dialog[data-panel="controls"] {width: min(565px,calc(100% - 14px));}
  .rules-fields {grid-template-columns: minmax(0,.75fr) minmax(0,.85fr) minmax(0,1.4fr);}
  .rules-fields label:last-child {grid-column: auto;}
}


@supports not (width: 1cqh) {
  .board-well > .board-shell:not(.focused) {width: var(--fit-side,100%); height: var(--fit-side,auto);}
  .board-well > .board-shell {padding: 2px;}
  .board-well .focused #board {width: max(735px,142%);}
  .board-well .axis,.board-well .sq {font-size: clamp(7px,calc(var(--fit-side,500px) * .021),15px);}
  .board-well .sq.tile {font-size: clamp(10px,calc(var(--fit-side,500px) * .04),45px);}
  .board-well .focused .sq.tile {font-size: 28px;}
}

/* Rack gestures never change the tile's identity or its board placement. */
.racktile {touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab;}
.racktile.dragging {z-index: 3; cursor: grabbing; box-shadow: 0 5px 12px #172e2a55;}
.racktile.drop-slot {outline: 3px dashed var(--brand);outline-offset: -3px;}
.arranging .racktile {border-bottom: 3px solid #866c38;}
.arranging [data-act="arrange"] {background: var(--pale);border-radius: 6px;}
.arranging .racktile.selected {outline-offset: -2px;}
.rackbox .draftline {min-width: 0;}
.preview-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  max-width: 100%;min-height: 36px;margin: 0;padding: 3px 9px;
  border: 1px solid var(--line);border-radius: 6px;background: var(--pale);color: var(--brand);
  font: 650 .88rem/1.2 var(--sans);cursor: pointer;
}
.preview-link .btnlabel {overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.preview-link .ico {width: 15px;height: 15px;flex: none;}
.preview-link.has-issue {color: var(--text);border-style: dashed;background: var(--surface);}
.table-play .board-well .sq[data-mark="word"] {outline: 2px solid #267262;outline-offset: -2px;}
.table-play .board-well .sq[data-mark="placed"],.table-play .board-well .sq[data-mark="premium"] {
  outline: 3px double #764513;outline-offset: -3px;background: #ffe39c;color: #2f301c;
}
.table-play .board-well .sq[data-mark="issue"] {
  outline: 2px dashed #8d2536;outline-offset: -2px;background: #ffe1dd;color: #392224;
}
.board-well .sq[data-mark]:focus-visible {box-shadow: inset 0 0 0 4px #397ab0;}
.table-heading.replaying :is(.table-context,.small-status,#turntext) {display: none;}
.play-recap {min-width: 0;border-inline-start: 3px solid #bd9450;padding-inline-start: 8px;}
.play-recap small,.play-recap strong {display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
.play-recap small {font: 600 .81rem/1.3 var(--sans);color: var(--sub);}
.play-recap .recap-words {min-width: 0;overflow: hidden;text-overflow: ellipsis;}
.play-recap .recap-score {flex: none;font-weight: inherit;}
.play-recap strong {display: flex;align-items: baseline;gap: .35em;font: 700 clamp(1.2rem,2.25vw,2.15rem)/1.13 var(--serif);color: var(--text);}
@media(prefers-reduced-motion:no-preference) {
  .play-recap:not([hidden]) {animation: play-appear .22s ease-out;}
  @keyframes play-appear {from {opacity: .65;transform: translateY(2px);}to {opacity: 1;transform: none;}}
}
.score-total,.word-heading {display: flex;align-items: baseline;justify-content: space-between;gap: 8px;}
.score-total {font-weight: 600;}
.score-total strong {font: 700 1.7rem/1.2 var(--serif);color: var(--brand);}
.word-choices,.tally-tiles,.applied-premiums {display: flex;flex-wrap: wrap;gap: 5px;}
.word-choices {margin: 8px 0;}
.word-choices button {min-height: 44px;min-width: 44px;padding: 5px 9px;overflow-wrap: anywhere;}
.word-choices button[aria-pressed="true"] {background: var(--brand);color: var(--brandwhite);}
.word-tally {border-block-start: 1px solid var(--line);margin-top: 8px;padding-top: 9px;}
.word-heading h3 {margin: 0;overflow-wrap: anywhere;}
.word-heading b {white-space: nowrap;}
.word-tally p,.placement-message {margin: 9px 0;}
.tally-tiles {margin-top: 8px;}
.tally-tile {padding: 2px 5px;border: 1px solid var(--line);background: var(--paper);border-radius: 4px;font-variant-numeric: tabular-nums;}
.tally-tile b {font-family: var(--serif);}
.tally-tile small {font-size: .75rem;}
.tally-tile.letter-premium {border-style: double;border-width: 3px;padding: 0 3px;}
.applied-premiums {margin-bottom: 8px;}
.applied-premiums span,.rack-bonus {background: var(--pale);color: var(--text);border-radius: 4px;padding: 3px 7px;font-size: .87rem;}
.rack-bonus {margin: 8px 0 0;}
.replay-link {min-height: 44px;padding: 4px 7px;}
@media (max-height:550px) {
  .table-play .preview-link {min-height: 32px;}
  .play-recap small {font-size: .74rem;}
  .score-total strong {font-size: 1.35rem;}
  .word-tally {margin-top: 4px;padding-top: 4px;}
  .word-tally p,.word-choices,.applied-premiums {margin: 3px 0;}
  .tally-tiles {margin-top: 3px;}
}

@media (max-width: 440px) {
  .play-recap .recap-verb {display: none;}
}

/* The reveal replaces the rack, so the board keeps its own space on a phone. */
.round-panel {min-width: 0;border: 1px solid var(--line);border-radius: 10px;background: var(--surface);padding: 6px 9px;}
.result-heading,.round-footer {display: flex;align-items: center;justify-content: space-between;gap: 8px;}
.result-heading h2,.round-heading {font: 700 clamp(1.05rem,1.8vw,1.5rem)/1.1 var(--serif);margin: 0;}
.result-heading button,.round-footer button {min-height: 44px;padding: 4px 8px;}
.round-entries {list-style: none;display: grid;gap: 2px;margin: 3px 0;padding: 0;}
.round-entries li {display: grid;grid-template-columns: minmax(0,.8fr) minmax(0,1.3fr) auto;align-items: baseline;gap: 6px;padding: 3px 5px;border-bottom: 1px solid var(--line);}
.result-name,.result-word {min-width: 0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
.result-word {font-weight: 650;}
.result-points {font-variant-numeric: tabular-nums;}
.round-entries .board-choice {background: var(--pale);border-radius: 4px;}
.board-star {color: var(--brand);}
.round-key {color: var(--sub);font-size: .85rem;}
.full-words .result-word,.full-words .result-name,.detail-content .short-standings td {white-space: normal;overflow-wrap: anywhere;}
.short-standings {table-layout: fixed;}
.short-standings th:first-child {width: 32%;}
.short-standings th:last-child {width: 18%;}
.short-standings :is(td,th):nth-child(2) {text-align: left;}
.round-panel .short-standings :is(td,th) {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
.short-standings td b {white-space: nowrap;}
.round-panel .finish-actions {margin-top: 4px;}
.short-final .last-play,.round-reveal .last-play {display: none;}
.short-final .side-scores {display: none;}
.round-reveal .side-turns {display: none;}
.round-reveal .side-links [data-act="turns"] {display: inline-flex;}
@media (min-width:1000px) and (min-height:700px) {
  .round-panel {padding: 10px 14px;}
  .round-entries li {padding: 6px 5px;}
  .table-play.shared .round-entries {font-size: clamp(1rem,1.3vw,1.4rem);}
}
@media (max-height:650px) and (max-width:739px) {
  .round-panel {padding: 2px 5px;}
  .round-entries {gap: 0;margin: 0;}
  .round-entries li {line-height: 1.13;padding: 2px 3px;}
  .round-panel .short-standings :is(th,td) {padding-block: 2px;}
}
@media (max-width:520px) and (max-height:600px) {
  .table-play.short-final .round-footer {min-height: 0;}
  .short-final .round-panel .finish-actions button {padding: 3px 6px;}
}

@media (max-width:739px) and (max-height:620px) {
  .round-reveal:not(.short-final) .round-panel {display: grid;grid-template-columns: minmax(0,1fr) auto;align-items: center;}
  .round-reveal:not(.short-final) :is(.result-heading,.round-footer) {display: contents;}
  .round-reveal:not(.short-final) .result-heading h2 {grid-area: 1/1;}
  .round-reveal:not(.short-final) .round-footer :is(button,.muted) {grid-area: 1/2;}
  .round-reveal:not(.short-final) .round-entries {grid-area: 2/1/3/-1;}
  .round-reveal:not(.short-final) .result-heading button,.round-reveal:not(.short-final) .round-footer .round-key {display: none;}
  .short-final .result-heading {display: none;}
  .round-panel .short-standings {font-size: .91rem;line-height: 1.12;}
  .round-panel .short-standings :is(td,th) {font-size: inherit;line-height: inherit;padding-block: 2px;}
  .round-panel .short-standings td strong {font-size: 1rem;line-height: 1;}
}

.setup-names > label {min-width: 0;}
@media (max-width:479px) and (max-height:600px) {
  .setup-names {grid-template-columns: repeat(2,minmax(0,1fr));align-items: end;}
  .setup-names .format-field {grid-column: 1/-1;}
}
@media (min-width:480px) and (max-height:550px) {
  .setup-names {grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1.4fr);align-items: end;}
  .setup-names .format-field:last-child:nth-child(3) {grid-column: span 2;}
}

/* The notice opens in its own sheet so a long message fits a small phone. */
.admin-link {display:inline-flex;align-items:center;min-height:44px;text-decoration:none;}
.home-notice {display:flex;gap:.45rem;align-items:center;max-width:100%;min-height:32px;padding:0;background:transparent;border:0;color:#fff3d5;text-align:left;}
.home-notice .btnlabel {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:underline;text-underline-offset:3px;}
.home-notice .ico {flex:none;width:17px;}
body[data-screen="home"] .hero h1.long-heading {font-size:clamp(1.65rem,4.2vw,3.4rem);overflow-wrap:anywhere;line-height:1.03;}
body[data-screen="home"] .hero-copy {min-width:0;}
body[data-screen="home"] .hero .hosting-paused {margin:0 0 5px;font-size:.95rem;color:#fff3d5;}
@media (max-height:560px) {body[data-screen="home"] .hero-copy h1.long-heading {font-size:1.6rem;}}

/* Scores, transfers and replays open over the table so the rack keeps its space. */
.night-card {width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums;}
.night-card caption {text-align:left;color:var(--sub);padding-bottom:.65rem;}
.night-card th,.night-card td {text-align:right;padding:5px 4px;}
.night-card th:first-child,.night-card .night-best td {text-align:left;}
.night-card th[scope="row"] {overflow-wrap:anywhere;}
.night-best td {font-size:.87rem;color:var(--sub);border-bottom:1px solid var(--line);}
.night-best strong {color:var(--text);overflow-wrap:anywhere;}
.transfer-box {display:grid;place-items:center;gap:12px;text-align:center;}
.transfer-box img {width:min(220px,58vw,38vh);height:auto;}
.transfer-box p {margin:0 0 .55rem;}
.transfer-box button {margin:2px 3px;}
.seat-confirm {max-width:32rem;margin:clamp(12px,7vh,70px) auto;}
.seat-confirm .textlink {margin-inline-start:.7rem;}
dialog[data-panel="comparison"] {width:fit-content;max-width:calc(100vw - 12px);}
.comparison {display:grid;align-items:center;gap:12px;}
.comparison-board {--size:min(75vh,48vw,650px);inline-size:var(--size);aspect-ratio:1;display:grid;grid-template:repeat(15,minmax(0,1fr))/repeat(15,minmax(0,1fr));padding:2px;gap:1px;background:var(--board);border:3px solid var(--frame);box-sizing:border-box;container-type:inline-size;}
.cmp-cell {display:grid;place-items:center;position:relative;min-width:0;min-height:0;background:var(--square);color:var(--sub);font:bold 2.2cqw/1 var(--sans,sans-serif);}
.cmp-cell.letter {font:bold 4.3cqw/1 var(--serif,serif);background:var(--tile-top);color:var(--inktile);}
.cmp-cell.letter small {position:absolute;right:2%;bottom:2%;font:600 1.7cqw/1 var(--sans,sans-serif);}
.cmp-cell.placed {background:var(--draft-top);color:var(--draft-ink);outline:2px solid var(--cursor);outline-offset:-2px;}
.cmp-cell.connected {box-shadow:inset 0 -3px var(--recent);}
.cmp-cell.DL {background:var(--dl);color:var(--dl-ink);}
.cmp-cell.TL {background:var(--tl);color:var(--tl-ink);}
.cmp-cell.DW {background:var(--dw);color:var(--dw-ink);}
.cmp-cell.TW {background:var(--tw);color:var(--tw-ink);}
.comparison-info {min-width:0;overflow-wrap:anywhere;}
.comparison-info p,.comparison-info h3 {margin:0 0 .45rem;}
.comparison-rank {color:var(--sub);font-weight:650;}
.comparison-info h3 {font-size:clamp(1.15rem,3vw,2rem);}
.comparison-info h3 strong {white-space:nowrap;color:var(--brand);}
.comparison-buttons {display:flex;gap:6px;}
.comparison-buttons button,.transfer-box button {min-height:44px;}
@media (min-width:600px),(orientation:landscape) {
  .comparison {grid-template-columns:auto minmax(150px,240px);}
  .comparison-board {--size:min(69vh,49vw,650px);}
}
@media (max-width:599px) and (orientation:portrait) {
  .comparison-board {--size:min(82vw,calc(var(--dialog-height,100vh) - 260px));margin-inline:auto;}
  .comparison {max-width:85vw;gap:6px;}
}
@media (max-height:550px) and (orientation:landscape) {
  .transfer-box {grid-template-columns:auto 1fr;text-align:left;}
  .transfer-box img {width:min(36vw,55vh);}
  .night-card th,.night-card td {padding-block:2px;}
}
