#kibitz-screen {
  --kb-window: #d5e0dc; --kb-panel: #16231f; --kb-surface: #ffffff;
  --kb-soft: #e5ece9; --kb-text: #17231f; --kb-muted: #5b6964;
  --kb-line: #aebcb7; --kb-primary: #075d48; --kb-felt: #17694f;
  --kb-table: #d5e0dc; --kb-player: #fbfdf9; --kb-card: #ffffff;
  --kb-communication: #f4efe4; --kb-information: #fff8dd;
  --kb-communication-text: #17231f; --kb-information-text: #17231f;
  --kb-button: #21483d; --kb-button-text: #f4fff9; --kb-player-soft: #e7ece9;
  --kb-hand-width: 220px; --kb-horizontal-hand-width: 345px;
  --kb-hand-min-height: 176px; --kb-hand-font: 35px; --kb-played-font: 34px;
  --kb-hand-heading-font: 18px; --kb-seat-font: 28px; --kb-auction-font: 25px;
  position: fixed; inset: 0; z-index: 80; display: none; overflow: auto;
  --kb-ui-font: 19px; color: var(--kb-text); background: var(--kb-table); font-size: var(--kb-ui-font);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
#kibitz-screen[data-size="compact"] {
  --kb-hand-width: 192px; --kb-horizontal-hand-width: 300px;
  --kb-hand-min-height: 151px; --kb-hand-font: 29px;
  --kb-hand-heading-font: 15px; --kb-seat-font: 23px; --kb-auction-font: 21px;
}
#kibitz-screen[data-size="large"] {
  --kb-hand-width: 245px; --kb-horizontal-hand-width: 385px;
  --kb-hand-min-height: 201px; --kb-hand-font: 39px;
  --kb-hand-heading-font: 20px; --kb-seat-font: 32px; --kb-auction-font: 29px;
}
#kibitz-screen[data-font-size="standard"] { --kb-ui-font: 16px; --kb-hand-heading-font: 15px; --kb-auction-font: 21px; }
#kibitz-screen[data-font-size="large"] { --kb-ui-font: 19px; --kb-hand-heading-font: 18px; --kb-auction-font: 25px; }
#kibitz-screen[data-font-size="extra-large"] { --kb-ui-font: 22px; --kb-hand-heading-font: 21px; --kb-auction-font: 29px; }
#kibitz-screen.on { display: block; }
#kibitz-screen * { box-sizing: border-box; }
body.kibitz-mode #topbar, body.kibitz-review-mode #topbar { display: none !important; }
#kibitz-screen button, #kibitz-screen select {
  min-height: 38px; padding: 6px 9px; color: inherit; border: 1px solid var(--kb-line);
  border-radius: 4px; background: var(--kb-player); font: inherit;
}
#kibitz-screen button:focus-visible, #kibitz-screen input:focus-visible,
#kibitz-screen select:focus-visible { outline: 3px solid #f2c744; outline-offset: 2px; }
.kb-topbar {
  position: sticky; top: 0; z-index: 30; display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  min-height: 50px; padding: 4px 9px; color: var(--kb-panel-text);
  border-bottom: 1px solid #52645d; background: var(--kb-panel);
}
.kb-brand { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-weight: 600; }
.kb-brand img { width: 40px; height: 40px; object-fit: contain; }
.kb-title { display: flex; min-width: 0; align-items: baseline; justify-content: center; gap: 9px; }
.kb-title strong { color: #f4d465; font-size: 1em; letter-spacing: .04em; text-transform: uppercase; }
.kb-title span { overflow: hidden; color: #ffffff; text-overflow: ellipsis; white-space: nowrap; }
.kb-scroll-cue { display: none; }
.kb-scroll-cue[hidden] { display: none !important; }
#kb-live-status { max-width: 520px; margin: 0; color: var(--kb-panel-text); font-size: .8em; line-height: 1.2; }
.kb-topbar button { min-height: 34px !important; color: #ffffff !important; border-color: #ffffff66 !important; background: #ffffff12 !important; }
.kb-fullscreen-exit { font-weight: 700; }
.kb-body {
  display: grid; grid-template-areas: "controls workspace context";
  grid-template-columns: 190px minmax(560px, 1fr) 270px;
  height: calc(var(--kb-viewport-height, 100dvh) - 50px); min-height: 0; background: var(--kb-table);
}
.kb-body[data-panel-side="right"] {
  grid-template-areas: "context workspace controls";
  grid-template-columns: 270px minmax(560px, 1fr) 190px;
}
.kb-controls {
  grid-area: controls; position: relative; display: flex; min-width: 0; min-height: 0;
  overflow-y: auto; flex-direction: column; gap: 7px;
  color: var(--kb-panel-text, #f4fbf8); border-right: 1px solid #52645d;
  background: var(--kb-panel);
}
.kb-body[data-panel-side="right"] .kb-controls { border-right: 0; border-left: 1px solid #52645d; }
.kb-control-heading { display: grid; gap: 2px; padding: 9px 10px 5px; }
.kb-control-heading strong { color: #f4d465; font-size: 1.25em; font-weight: 600; text-transform: uppercase; }
.kb-control-heading span { color: #d1e1db; font-size: .8em; font-weight: 600; }
.kb-board { display: grid; justify-items: center; color: var(--kb-information-text); border-block: 1px solid #c9c0a8; background: var(--kb-information); }
.kb-board .board-diagram { display: block; width: 116px; height: 116px; margin: 7px auto 3px; }
.kb-vulnerability { display: flex; width: 100%; align-items: center; justify-content: center; gap: 6px; padding: 5px; color: #a51e22; border-top: 1px solid #b8aa89; background: #e4d6b5; }
.kb-vulnerability strong { font-size: 1em; }
#kibitz-screen .kb-contract {
  display: grid; width: 100%; min-height: 68px; place-items: center; gap: 0; padding: 6px;
  color: var(--kb-information-text); border: 0; border-radius: 0; background: var(--kb-information);
}
.kb-contract span, .kb-contract small { color: inherit; font-size: .78em; }
.kb-contract strong { color: inherit; font-size: 1.28em; font-weight: 600; }
.kb-trick-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px 7px; }
#kibitz-screen .kb-trick-counts button { min-width: 0; min-height: 58px; color: var(--kb-information-text); border: 2px solid #8bb5a6; background: var(--kb-information); }
.kb-trick-counts span { display: block; color: inherit; font-size: .78em; }
.kb-trick-counts strong { display: block; font-size: 1.4em; font-weight: 600; }
.kb-controls > button, .kb-perspective-wrap, .kb-replay-controls, .kb-replay-speed, .kb-more-panel { margin-inline: 7px; }
.kb-primary { color: #173126 !important; border-color: #f4d465 !important; background: #f4d465 !important; font-weight: 700 !important; }
#kibitz-screen .kb-controls > button:not(.kb-primary):not(.kb-leave) { color: var(--kb-button-text); border-color: #60716b; background: var(--kb-button); }
#kb-switch-room { font-size: .85em; white-space: nowrap; }
.kb-perspective-wrap { display: grid; gap: 4px; }
.kb-perspective-wrap > span, .kb-more-panel > span { color: #cbdad5; font-size: .8em; }
.kb-perspectives { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
#kibitz-screen .kb-perspectives button { min-width: 0; padding-inline: 3px; color: #17231f; font-size: .82em; }
.kb-perspectives button:first-child { grid-column: 1 / -1; }
.kb-perspectives button[aria-pressed="true"], .kb-panel-side button[aria-pressed="true"],
.kb-replay-controls button[aria-pressed="true"] { color: var(--kb-button-text) !important; border-color: var(--kb-button) !important; background: var(--kb-button) !important; }
.kb-replay-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
#kibitz-screen .kb-replay-controls button { min-width: 0; padding-inline: 2px; color: var(--kb-button-text); border-color: #60716b; background: var(--kb-button); font-size: .8em; }
#kibitz-screen .kb-replay-controls button:disabled { opacity: .48; }
.replay-speed-control { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); align-items: center; gap: 3px; }
.replay-speed-control > span { display: grid; width: 28px; height: 28px; place-items: center; color: inherit; font-size: .9em; }
#kibitz-screen .replay-speed-control button { min-width: 0; min-height: 32px; padding: 2px 3px; color: #dce9e4; border-color: #60716b; background: transparent; font-size: .76em; }
#kibitz-screen .replay-speed-control button[aria-pressed="true"] { color: #17231f; border-color: #f4d465; background: #f4d465; font-weight: 800; }
.kb-popover { position: absolute; z-index: 32; top: 420px; left: 7px; right: 7px; padding: 10px; color: #17231f; border: 1px solid var(--kb-line); border-radius: 5px; background: #ffffff; box-shadow: 0 12px 24px #0005; }
.kb-popover ul { margin: 5px 0; padding-left: 20px; }
.kb-more-panel { display: grid; gap: 8px; padding: 9px; color: #17231f; border: 1px solid var(--kb-line); border-radius: 5px; background: #ffffff; }
.kb-more-panel[hidden], .kb-popover[hidden] { display: none; }
.kb-more-panel h2 { margin: 0; font-size: 1em; }
.kb-more-panel button { width: 100%; color: var(--kb-button-text) !important; background: var(--kb-button) !important; }
.kb-director-compose { display: grid; gap: 5px; margin-inline: 7px; padding: 8px; color: #17231f; background: #fff; border: 1px solid var(--kb-line); border-radius: 5px; }
.kb-director-compose[hidden], .kb-director-compose [hidden] { display: none; }
.kb-director-compose label { font-size: .78em; font-weight: 700; }
.kb-director-compose select, .kb-director-compose textarea { width: 100%; min-width: 0; font: inherit; }
.kb-director-compose textarea { resize: vertical; }
.kb-director-compose button { min-height: 40px; }
.kb-director-compose p { margin: 0; overflow-wrap: anywhere; }
#kb-director-thread { display: grid; gap: 3px; max-height: 140px; overflow-y: auto; font-size: .8em; }
#kb-director-thread p { padding: 3px; background: #eef3f1; }
.kb-colours { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.kb-colours label, .kb-size-label { margin: 0; color: #5b6964; font-size: .78em; letter-spacing: 0; text-transform: none; }
.kb-colours select { width: 100%; min-height: 32px; margin: 3px 0 0; padding: 2px; border: 1px solid var(--kb-line); background: var(--kb-player); }
.kb-size-label { display: grid; gap: 3px; }
.kb-size-label select { width: 100%; min-height: 34px !important; }
.kb-panel-side { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.kb-leave { margin-top: auto !important; margin-bottom: 8px !important; color: #12211c !important; border-color: #f4d465 !important; background: #f4d465 !important; font-weight: 600 !important; }
.kb-workspace { grid-area: workspace; position: relative; min-width: 0; min-height: 0; padding: 7px; background: var(--kb-felt); }
.kb-score-panel { top: 50%; right: auto; left: 50%; width: min(490px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; transform: translate(-50%, -50%); }
.kb-score-panel[hidden] { display: none; }
.kb-felt { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 650px; overflow: hidden; border: 2px solid #0a3e31; border-radius: 0; background: var(--kb-felt); box-shadow: inset 0 0 60px #00000029; }
.kb-felt::before { display: none; }
.kb-felt-caption { position: absolute; z-index: 8; top: 7px; left: 8px; display: flex; align-items: center; gap: 7px; color: #ffffff; font-size: .8em; }
.kb-felt-caption strong { padding: 4px 7px; color: #173126; border-radius: 3px; background: #f7f7f2; }
.kb-felt-caption span { padding: 0; color: #ffffff; background: transparent; }
.kb-hand { position: absolute; z-index: 3; overflow: hidden; width: var(--kb-hand-width); min-height: var(--kb-hand-min-height); padding: 0; color: var(--kb-player-text, #142820); border: 2px solid #d9e3df; border-radius: 3px; background: var(--kb-player); box-shadow: 0 5px 14px #0000003d; }
.kb-hand[data-position="n"], .kb-hand[data-position="s"] { left: 50%; width: var(--kb-horizontal-hand-width); transform: translateX(-50%); }
.kb-hand[data-position="n"] { top: 22px; }
.kb-hand[data-position="s"] { bottom: 13px; }
.kb-hand[data-position="w"] { top: 50%; left: 7px; transform: translateY(-50%); }
.kb-hand[data-position="e"] { top: 50%; right: 7px; transform: translateY(-50%); }
.kb-hand-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 50px; align-items: center; gap: 0; padding: 0 0 0 58px; border-bottom: 1px solid #b8c8c2; background: var(--kb-player-soft); font-size: var(--kb-hand-heading-font); font-weight: 600; }
.kb-hand-head > span:first-child { overflow: hidden; padding: 0 8px; text-overflow: ellipsis; white-space: nowrap; }
.kb-seat-marker { position: absolute; z-index: 2; top: 0; left: 0; display: grid; width: 58px; height: 50px; place-items: center; color: #ffffff; border: 0; border-radius: 0; background: #185b4c; font-size: var(--kb-seat-font); font-weight: 600; }
.kb-seat-marker.vulnerable { background: #a9221b; }
.kb-role { padding-right: 8px; color: #52635d; font-size: .78em; }
.kb-suits { display: grid; grid-template-columns: 31px minmax(0, 1fr); gap: 0 5px; padding: 7px 9px 9px; font: 600 var(--kb-hand-font)/1.02 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.kb-suits .red { color: #b51f37; }
.kb-suit-row { display: contents; }
.kb-ranks { display: flex; min-width: 0; gap: .34em; overflow: hidden; }
.kb-rank { flex: 0 0 auto; }
.kb-card-suit { display: none; }
.kb-card-rank { display: inline; }
.kb-hand.kb-seat-label-only { display: block; min-height: 0; height: auto; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.kb-seat-label-only .kb-hand-head { border: 1px solid var(--kb-line); border-radius: 3px; }
.kb-turn-dot { position: absolute; z-index: 7; width: 30px; height: 30px; border: 3px solid #fff2b4; border-radius: 50%; background: #f2c744; box-shadow: 0 2px 8px #0007; }
.kb-hand[data-position="n"] .kb-turn-dot { bottom: -15px; left: 50%; transform: translate(-50%, 50%); }
.kb-hand[data-position="s"] .kb-turn-dot { top: -15px; left: 50%; transform: translate(-50%, -50%); }
.kb-hand[data-position="w"] .kb-turn-dot { top: 50%; right: -15px; transform: translate(50%, -50%); }
.kb-hand[data-position="e"] .kb-turn-dot { top: 50%; left: -15px; transform: translate(-50%, -50%); }
.kb-observed-auction { position: absolute; z-index: 6; top: 50%; left: 50%; width: 285px; max-height: 300px; overflow: auto; padding: 0; color: #17231f; border: 2px solid #33594d; border-radius: 3px; background: #dfe9e5; box-shadow: 0 8px 24px #0000004d; transform: translate(-50%, -50%); }
.kb-observed-auction h2 { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; margin: 0; padding: 6px 9px; background: #c8d8d2; font-size: .82em; }
.kb-auction-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px 8px 10px; text-align: center; font-size: var(--kb-auction-font); font-weight: 600; line-height: 1.12; }
.kb-auction-grid > * { display: flex; min-width: 0; min-height: 39px; align-items: center; justify-content: center; gap: 1px; padding: 2px; border: 0; border-radius: 0; background: transparent; white-space: nowrap; }
.kb-auction-grid .head { position: sticky; top: 32px; z-index: 3; min-height: 34px; color: #ffffff; background: #1c5b4c; font-size: calc(var(--kb-auction-font) * .76); }
.kb-auction-grid button { color: #624b0c; background: #fff1b8; text-decoration: underline dotted; text-underline-offset: 5px; }
.kb-auction-grid .sy { display: inline; line-height: 1; }
.kb-auction-explanation { position: sticky; bottom: 0; margin: 0; padding: 8px; border-top: 1px solid #91b2a3; background: #fff9d8; font-size: .82em; }
.kb-auction-explanation[hidden] { display: none; }
.kb-observed-trick { position: absolute; z-index: 4; top: 50%; left: 50%; width: 270px; height: 220px; transform: translate(-50%, -50%); }
.kb-played { position: absolute; display: grid; width: 72px; height: 92px; place-items: center; color: #17222b; border-radius: 4px; background: var(--kb-card); box-shadow: 0 5px 14px #00000052; font: 600 var(--kb-played-font) ui-monospace, SFMono-Regular, Menlo, monospace; }
.kb-played.red { color: #b51f37; }
.kb-played[data-position="n"] { top: 0; left: 99px; }
.kb-played[data-position="e"] { top: 64px; right: 0; }
.kb-played[data-position="s"] { bottom: 0; left: 99px; }
.kb-played[data-position="w"] { top: 64px; left: 0; }
.kb-result-message { position: absolute; z-index: 9; top: 52px; left: 50%; width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 9px 14px; color: #3e310d; border: 2px solid #c09218; border-radius: 4px; background: #fff4c5; box-shadow: 0 5px 15px #0003; font-weight: 800; text-align: center; transform: translateX(-50%); }
.kb-result-message[hidden] { display: none; }
.kb-waiting-message {
  position: absolute; z-index: 9; top: 50%; left: 50%; display: grid;
  width: min(430px, calc(100% - 300px)); gap: 7px; padding: 18px 22px;
  color: #243129; border: 3px solid #e1b72f; border-radius: 5px;
  background: #fff8d8; box-shadow: 0 10px 28px #0006; text-align: center;
  transform: translate(-50%, -50%);
}
.kb-waiting-message strong { font-size: 1.14em; }
.kb-waiting-message span { font-size: .9em; line-height: 1.35; }
.kb-waiting-message[hidden] { display: none; }
.kb-context { grid-area: context; display: flex; min-width: 0; min-height: 0; overflow: hidden; flex-direction: column; gap: 8px; padding: 10px; color: var(--kb-communication-text); border-left: 1px solid var(--kb-line); background: var(--kb-communication); }
.kb-body[data-panel-side="right"] .kb-context { border-right: 1px solid var(--kb-line); border-left: 0; }
.kb-context:has(> #kb-information[hidden]):has(> #kb-chat-slot[hidden]) { display: none; }
.kb-chat-slot { flex: 1 1 50%; min-width: 0; min-height: 260px; overflow: hidden; border-top: 2px solid var(--kb-line); background: var(--kb-communication); }
.kb-chat-slot[hidden] { display: none; }
body.kibitz-mode #direct-chat-host { position: static; width: 100%; height: 100%; min-height: 0; padding: 0; background: transparent; }
.kb-information { min-width: 0; overflow: auto; padding: 9px; color: var(--kb-information-text); border: 1px solid var(--kb-line); border-radius: 4px; background: var(--kb-information); }
.kb-information[hidden] { display: none; }
.kb-information-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kb-information h2 { margin: 0; font-size: 1.05em; }
.kb-info-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--kb-line); }
.kb-info-row-main { display: grid; gap: 2px; }
.kb-info-row-main small { color: var(--kb-muted); }
.kb-trick-cards { font: 700 15px ui-monospace, SFMono-Regular, Menlo, monospace; }
.kb-trick-winner { color: var(--kb-primary); }
#kibitz-screen:fullscreen { overflow: auto; background: var(--kb-table); }
#kibitz-screen:fullscreen .kb-topbar { position: sticky; }
#kibitz-screen:fullscreen .kb-fullscreen { display: none; }
#kibitz-screen:fullscreen .kb-fullscreen-exit { display: block !important; }
@media (max-width: 1100px) {
  .kb-body, .kb-body[data-panel-side="right"] {
    grid-template-areas: "workspace workspace" "controls context";
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: auto; min-height: calc(var(--kb-viewport-height, 100dvh) - 50px);
  }
  .kb-workspace { height: 650px; }
  .kb-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; overflow: visible; padding: 8px; border-top: 1px solid #52645d; border-right: 0; }
  .kb-control-heading { grid-column: 1; padding: 0; }
  .kb-board { grid-column: 2; grid-row: 1 / span 4; }
  .kb-board .board-diagram { width: 92px; height: 92px; }
  .kb-contract { grid-column: 3; grid-row: 1 / span 2; }
  .kb-trick-counts { grid-column: 4; grid-row: 1 / span 2; padding: 0; }
  .kb-controls > button, .kb-perspective-wrap, .kb-replay-controls, .kb-replay-speed, .kb-more-panel { margin-inline: 0; }
  .kb-perspective-wrap { grid-column: 1 / span 2; }
  .kb-replay-controls { grid-column: 3 / span 2; }
  .kb-replay-speed { grid-column: 3 / span 2; }
  .kb-more-panel, .kb-director-compose { grid-column: 1 / -1; }
  .kb-leave { margin: 0 !important; }
  .kb-context { border-top: 1px solid var(--kb-line); border-left: 1px solid var(--kb-line); }
  .kb-popover { position: fixed; top: auto; right: 12px; bottom: 70px; left: 12px; }
}
@media (max-width: 700px) {
  #kibitz-screen.on { display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  .kb-topbar { position: relative; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
  .kb-brand span, .kb-fullscreen { display: none; }
  .kb-title { display: grid; justify-content: start; gap: 1px; }
  .kb-title strong { font-size: 1em; }
  .kb-title span { display: block; overflow: visible; white-space: normal; overflow-wrap: anywhere; font-size: .76em; line-height: 1.15; }
  .kb-scroll-cue { display: block; min-height: 36px !important; padding: 3px 6px !important; font-size: .7em !important; white-space: nowrap; }
  #kb-live-status { grid-column: 1 / -1; font-size: .75em; }
  .kb-body, .kb-body[data-panel-side="right"] { display: flex; min-height: 0; overflow: auto; flex-direction: column; }
  .kb-workspace { order: 1; height: auto; min-height: 0; padding: 5px; flex: 0 0 auto; }
  .kb-felt { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; height: auto; min-height: 0; padding: 42px 6px 6px; overflow: visible; }
  .kb-hand, .kb-hand[data-position="n"], .kb-hand[data-position="e"],
  .kb-hand[data-position="s"], .kb-hand[data-position="w"] { position: relative; inset: auto; width: 100%; min-height: 148px; transform: none; }
  .kb-hand-head { grid-template-columns: minmax(0, 1fr); min-height: 36px; padding-left: 39px; }
  .kb-hand-head > span:first-child { padding-left: 6px; }
  .kb-seat-marker { width: 39px; height: 36px; font-size: 20px; }
  .kb-role { display: none; }
  .kb-suits { grid-template-columns: 23px 1fr; padding: 6px; font-size: clamp(17px, 5.5vw, 23px); }
  .kb-observed-auction { position: relative; grid-column: 1 / -1; inset: auto; width: 100%; max-height: 250px; transform: none; }
  .kb-observed-trick { position: relative; grid-column: 1 / -1; inset: auto; height: 190px; margin: auto; transform: scale(.82); transform-origin: top center; }
  .kb-result-message { position: relative; grid-column: 1 / -1; inset: auto; width: auto; transform: none; }
  .kb-waiting-message { position: relative; grid-column: 1 / -1; inset: auto; width: auto; transform: none; }
  .kb-controls { order: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; padding: 7px; flex: 0 0 auto; }
  .kb-control-heading, .kb-board { display: none; }
  #kibitz-screen .kb-contract { grid-column: 1 / span 2; grid-row: auto; min-height: 52px; }
  .kb-contract small { display: none; }
  .kb-trick-counts { grid-column: 3 / span 2; grid-row: auto; }
  .kb-perspective-wrap { grid-column: 1 / -1; }
  .kb-perspectives { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kb-perspectives button:first-child { grid-column: auto; }
  .kb-replay-controls { grid-column: 1 / -1; }
  .kb-replay-speed { grid-column: 1 / -1; }
  .kb-controls > button { min-width: 0; min-height: 42px; margin: 0; padding: 3px; font-size: .78em; }
  #kibitz-screen[data-authority="director-live"] .kb-leave { grid-column: 1 / -1; }
  .kb-more-panel, .kb-director-compose { grid-column: 1 / -1; max-height: 45vh; overflow: auto; }
  .kb-context { order: 3; min-height: 230px; border-left: 0; flex: 0 0 auto; }
}

/* ENH-058 portrait-phone observation composition.  North/South spend one
   horizontal line per hand; the released auction and trick remain separate
   grid rows so neither can obscure a visible hand. */
@media (max-width: 560px) and (min-height: 500px) {
  #kibitz-screen { --kb-ui-font: 15px; --kb-hand-heading-font: 12px; --kb-seat-font: 19px; }
  #kibitz-screen.on { min-height: 100dvh; padding-top: env(safe-area-inset-top); }
  .kb-topbar { min-height: 50px; padding-inline:max(6px,env(safe-area-inset-left)) max(6px,env(safe-area-inset-right)); }
  .kb-brand img { width: 38px; height: 38px; }
  .kb-body, .kb-body[data-panel-side="right"] { min-height: 0; overscroll-behavior: contain; }
  .kb-workspace { width: 100%; padding: 4px; }
  .kb-felt {
    display:grid;grid-template-columns:132px minmax(0,1fr) 132px;
    grid-template-areas:"north north north" "auction auction auction" "west centre east" "trick trick trick" "south south south";
    grid-template-rows:auto auto minmax(150px,1fr) auto auto;
    gap:4px;width:100%;min-height:650px;padding:30px 4px 4px;overflow:hidden
  }
  #kb-hands { display: contents; }
  .kb-hand, .kb-hand[data-position="n"], .kb-hand[data-position="e"],
  .kb-hand[data-position="s"], .kb-hand[data-position="w"] {
    position:relative;inset:auto;width:100%;min-width:0;min-height:0;transform:none
  }
  .kb-hand[data-position="n"] { grid-area:north; }
  .kb-hand[data-position="s"] { grid-area:south; }
  .kb-hand[data-position="w"] { grid-area:west; align-self:center; }
  .kb-hand[data-position="e"] { grid-area:east; align-self:center; }
  .kb-hand-head { min-height:28px;padding-left:31px;font-size:12px; }
  .kb-seat-marker { width:31px;height:28px;font-size:18px; }
  .kb-role { display:block;padding-right:5px;font-size:9px; }
  .kb-hand[data-position="n"] .kb-turn-dot,
  .kb-hand[data-position="s"] .kb-turn-dot { width:20px;height:20px; }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-suits {
    display:flex;min-height:46px;align-items:stretch;gap:1px;padding:2px;overflow:hidden;white-space:normal;font-size:17px
  }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-suit-row,
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-ranks { display:contents; }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-suit-symbol,
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-void { display:none; }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-rank {
    display:grid;min-width:0;min-height:44px;place-items:center;flex:1 1 0;
    border:1px solid #afbbb6;border-radius:4px;background:var(--kb-card);color:#17222b;
    font:800 clamp(11px,3.2vw,15px)/1 Inter,system-ui,sans-serif
  }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-rank::after {
    content:attr(data-card-label);font:800 clamp(11px,3.2vw,15px)/1 Inter,system-ui,sans-serif
  }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-rank { font-size:0; }
  .kb-hand:is([data-position="n"],[data-position="s"]) .kb-rank.red::after { color:#b51f37; }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-suits {
    grid-template-columns:18px minmax(0,1fr);gap:0 2px;padding:4px;font-size:17px
  }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-ranks { gap:.2em; }
  .kb-observed-auction {
    position:relative;grid-area:auction;inset:auto;justify-self:center;width:min(310px,100%);
    max-height:180px;transform:none;overflow:auto
  }
  .kb-auction-grid { padding:4px;font-size:17px; }
  .kb-auction-grid > * { min-height:32px; }
  .kb-observed-trick {
    position:relative;grid-area:trick;inset:auto;width:230px;height:165px;margin:auto;
    transform:scale(.78);transform-origin:top center
  }
  .kb-result-message, .kb-waiting-message { grid-area:centre;align-self:start; }
  .kb-felt-caption { top:4px;left:5px; }
  .kb-controls { grid-template-columns:repeat(4,minmax(0,1fr));padding:6px; }
  .kb-controls > button { min-height:44px; }
  .kb-context { padding-bottom:max(10px,env(safe-area-inset-bottom)); }
}

/* Reference2 landscape-phone observation.  All disclosed hands remain visible;
   the auction/trick replaces the centre and commands stay in the right rail. */
@media (max-height: 560px) and (max-width: 1000px) {
  #kibitz-screen { --kb-ui-font:13px;--kb-hand-heading-font:10px;--kb-seat-font:16px;--kb-hand-font:17px; }
  #kibitz-screen.on { display:grid;grid-template-rows:auto minmax(0,1fr);overflow:hidden; }
  .kb-topbar { position:relative;grid-template-columns:auto minmax(0,1fr) auto auto;min-height:44px;padding:2px 5px;gap:5px; }
  .kb-brand img { width:36px;height:36px; }
  .kb-brand span,.kb-fullscreen { display:none; }
  .kb-title { justify-content:start; }
  .kb-scroll-cue { display:block;min-height:30px!important;padding:2px 5px!important;font-size:10px!important;white-space:nowrap; }
  #kb-live-status { font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
  .kb-body,.kb-body[data-panel-side="right"] {
    display:grid;grid-template-areas:"workspace controls";grid-template-columns:minmax(0,1fr) 128px;
    width:100%;height:100%;min-height:0;overflow:hidden
  }
  .kb-workspace { grid-area:workspace;width:100%;height:100%;min-height:0;padding:2px; }
  .kb-context { display:none; }
  .kb-controls {
    grid-area:controls;display:flex;min-width:0;min-height:0;overflow-y:auto;flex-direction:column;gap:3px;padding:2px;border-left:1px solid #52645d
  }
  .kb-controls>* { min-width:0; }
  .kb-control-heading,.kb-board,.kb-perspective-wrap,.kb-replay-speed { display:none; }
  .kb-contract { min-height:44px!important;padding:2px!important; }
  .kb-contract span,.kb-contract small { display:none; }
  .kb-trick-counts { grid-template-columns:1fr 1fr;gap:2px;padding:0; }
  #kibitz-screen .kb-trick-counts button { min-height:40px;padding:2px;font-size:10px; }
  .kb-controls > button,.kb-replay-controls,.kb-more-panel { margin-inline:0; }
  #kibitz-screen .kb-controls > button { width:100%;min-height:40px;padding:2px;font-size:10px;white-space:normal;overflow-wrap:anywhere; }
  .kb-replay-controls { grid-template-columns:1fr 1fr;gap:2px; }
  #kibitz-screen .kb-replay-controls button { min-height:38px;font-size:11px; }
  .kb-leave { margin:0!important; }
  .kb-more-panel { max-height:none;padding:3px;overflow:visible;font-size:10px; }
  .kb-felt {
    display:grid;grid-template-columns:190px minmax(180px,1fr) 250px;
    grid-template-rows:minmax(0,1fr) minmax(0,1fr) 60px;
    grid-template-areas:"west centre north" "east centre north" "south south south";
    gap:3px;width:100%;height:100%;min-height:0;padding:3px;overflow:hidden
  }
  #kb-hands { display:contents; }
  .kb-hand,.kb-hand[data-position="n"],.kb-hand[data-position="e"],
  .kb-hand[data-position="s"],.kb-hand[data-position="w"] {
    position:relative;inset:auto;width:100%;min-width:0;min-height:0;height:100%;transform:none;box-shadow:none
  }
  .kb-hand[data-position="n"] { grid-area:north; }
  .kb-hand[data-position="w"] { grid-area:west; }
  .kb-hand[data-position="e"] { grid-area:east; }
  .kb-hand[data-position="s"] { grid-area:south; }
  .kb-hand-head { grid-template-columns:minmax(0,1fr);min-height:24px;height:24px;padding-left:27px;font-size:10px; }
  .kb-seat-marker { width:27px;height:24px;font-size:15px; }
  .kb-role { display:none; }
  .kb-suits { grid-template-columns:18px minmax(0,1fr);gap:0 2px;padding:2px 4px;font-size:17px; }
  .kb-ranks { gap:.22em; }
  .kb-hand[data-position="s"] .kb-suits {
    display:flex;height:34px;min-height:34px;align-items:stretch;gap:1px;padding:1px;overflow:hidden;white-space:normal
  }
  .kb-hand[data-position="s"] .kb-suit-row,
  .kb-hand[data-position="s"] .kb-ranks { display:contents; }
  .kb-hand[data-position="s"] .kb-suit-symbol,
  .kb-hand[data-position="s"] .kb-void { display:none; }
  .kb-hand[data-position="s"] .kb-rank {
    display:grid;min-width:0;min-height:32px;place-items:center;flex:1 1 0;border:1px solid #afbbb6;
    border-radius:3px;background:var(--kb-card);color:transparent;font-size:0
  }
  .kb-hand[data-position="s"] .kb-rank::after { content:attr(data-card-label);color:#17222b;font:800 11px/1 Inter,system-ui,sans-serif; }
  .kb-hand[data-position="s"] .kb-rank.red::after { color:#b51f37; }
  .kb-observed-auction {
    position:relative;grid-area:centre;inset:auto;width:100%;height:100%;max-height:none;align-self:stretch;transform:none;overflow:auto
  }
  .kb-observed-trick {
    position:relative;grid-area:centre;inset:auto;width:250px;height:190px;align-self:center;justify-self:center;margin:auto;transform:scale(.78)
  }
  .kb-result-message,.kb-waiting-message { grid-area:centre;align-self:start; }
  .kb-felt-caption { display:none; }
}
@media (forced-colors: active) { .kb-turn-dot { border: 3px solid CanvasText; background: Highlight; } }
@media (prefers-reduced-motion: reduce) { #kibitz-screen * { scroll-behavior: auto !important; } }
#kibitz-screen .kb-hand.kb-seat-label-only { height: auto; min-height: 0; align-self: center; }

/* ENH-058 account-selected phone hands. */
@media (max-width: 560px) and (min-height: 500px) {
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-suits {
    display:flex;min-height:46px;align-items:stretch;justify-content:center;gap:clamp(6px,2vw,10px);
    padding:2px 4px;overflow:hidden;white-space:nowrap
  }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-suit-row {
    display:flex;min-width:0;align-items:center;flex:0 1 auto;gap:2px
  }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-ranks {
    display:flex;min-width:0;align-items:center;gap:2px;overflow:visible
  }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-suit-symbol {
    display:inline;min-width:15px;font:900 19px/1 Inter,system-ui,sans-serif
  }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-rank {
    display:inline;min-width:0;min-height:0;padding:0;color:#17222b;border:0;background:transparent;
    font:800 clamp(14px,4.1vw,18px)/1 Inter,system-ui,sans-serif
  }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-rank::after { content:none; }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-card-suit { display:none; }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-card-rank { display:inline; }
  :root[data-hand-display=diagram] .kb-hand:is([data-position="n"],[data-position="s"]) .kb-void { display:inline; }
}
@media (max-height: 560px) and (max-width: 1000px) {
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-suits {
    display:flex;height:34px;min-height:34px;align-items:stretch;justify-content:center;gap:10px;
    padding:1px 4px;overflow:hidden;white-space:nowrap
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-suit-row {
    display:flex;min-width:0;align-items:center;flex:0 1 auto;gap:2px
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-ranks {
    display:flex;min-width:0;align-items:center;gap:2px;overflow:visible
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-suit-symbol {
    display:inline;min-width:14px;font:900 17px/1 Inter,system-ui,sans-serif
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-rank {
    display:inline;min-width:0;min-height:0;padding:0;color:#17222b;border:0;background:transparent;font:800 16px/1 Inter,system-ui,sans-serif
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-rank::after { content:none; }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-card-suit { display:none; }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-card-rank { display:inline; }
  :root[data-hand-display=diagram] .kb-hand[data-position="s"] .kb-void { display:inline; }
}
@media (max-width: 560px) and (min-height: 500px), (max-height: 560px) and (max-width: 1000px) {
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand {
    display:flex;box-sizing:border-box;width:100%;height:100%;min-height:24px;align-items:stretch;
    justify-content:center;gap:7px;padding:1px 2px;overflow:hidden;white-space:normal
  }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-suit-row {
    display:flex;min-width:0;align-items:stretch;flex:0 1 auto
  }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-suit-symbol,
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-void { display:none; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-ranks {
    display:flex;min-width:0;align-items:stretch;gap:2px;overflow:visible
  }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-rank {
    display:flex;width:clamp(21px,6.2vw,28px);min-width:0;min-height:22px;align-items:center;justify-content:center;
    flex:0 1 28px;flex-direction:column;padding:1px;color:#17222b;border:1px solid #afbbb6;
    border-radius:3px;background:var(--kb-card);font-size:initial;line-height:.86
  }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-rank.red { color:#b51f37; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-rank::after { content:none; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-card-suit {
    display:block;font:900 clamp(11px,3.2vw,16px)/.9 Inter,system-ui,sans-serif
  }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-card-rank {
    display:block;font:850 clamp(10px,3vw,15px)/1 Inter,system-ui,sans-serif
  }
}
@media (max-width: 560px) and (min-height: 500px) {
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand { height:46px;min-height:46px; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-rank { min-height:42px; }
}
@media (max-height: 560px) and (max-width: 1000px) {
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand { height:34px;min-height:34px; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-rank { min-height:32px; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-card-suit { font-size:12px;line-height:.9; }
  :root[data-hand-display=cards] .kb-hand .kb-suits.kb-card-hand .kb-card-rank { font-size:11px;line-height:.95; }
}
