/* Keep the floors, account and crew in reach at every viewport width. */
#crew-jackpot-notice {
  position:fixed;z-index:40;inset:auto 12px calc(var(--status-height,48px) + 10px) auto;
  box-sizing:border-box;margin:0;max-width:min(30rem,calc(100% - 24px));padding:12px 16px;
  color:#ffedc0;background:#213a30;border:1px solid #aa8d53;border-radius:8px;
  box-shadow:inset 0 1px #e6cb9466,0 5px 18px #0b141755;
}
#crew-jackpot-notice strong{overflow-wrap:anywhere}
#crew-jackpot-notice button{margin-inline-start:10px;min-height:36px}
#app-header {
  grid-template-columns: minmax(max-content,1fr) auto minmax(max-content,1fr);
  gap: clamp(8px,1.5vw,24px);
  padding-inline: max(12px,calc((100vw - 1536px)/2));
}
#app-header #floor-nav { justify-content: center; gap: clamp(4px,1.2vw,20px); }
#hall-utilities { display: flex; align-items: center; justify-self: end; gap: clamp(4px,.75vw,12px); }
#hall-utilities #master-switch { white-space:nowrap;min-height:36px;padding:5px 10px;font-size:.82rem;background:var(--glass-light);color:#152d25;border:1px solid #a7cbb9;box-shadow:var(--glaze-shadow); }
#switch-game-dialog { width:min(450px,calc(100% - 24px));padding:clamp(18px,3vw,28px); }
#switch-game-dialog #switch-detail { margin:12px 0 18px;line-height:1.45;color:#e0e6d9; }
#switch-game-dialog #switch-target { width:100%;margin:5px 0 12px;min-height:42px; }
#switch-game-dialog #switch-message:empty { display:none; }
#switch-game-dialog #switch-message { margin-block:0 10px; }
#hall-utilities #scores-nav, #hall-utilities #return-room {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 6px 8px; border: 0; background: transparent; color: #dfd6bd;
  font: 650 .86rem/1.15 system-ui,sans-serif; box-shadow: none; text-decoration: none; white-space: nowrap;
}
#hall-utilities #scores-nav:is(:hover,[aria-current=page]), #hall-utilities #return-room:hover { color: #ffdda1; }
@media(max-width:1050px) {
  #app-header { grid-template-columns: auto minmax(0,1fr) auto; gap: 5px; }
  #app-header #floor-nav { gap: 4px; }
  #app-header .brand { font-size: 1.15rem; gap: 6px; }
  #hall-utilities { gap: 2px; }
}
@media(max-width:899px) {
  #app-header { grid-template-columns: minmax(0,1fr) auto; gap: 0 3px; padding-inline: max(8px,env(safe-area-inset-left)); }
  #app-header > .brand { grid-area: 1 / 1; }
  #app-header .brand img { width: 30px; height: 30px; }
  #app-header #hall-utilities { grid-area: 1 / 2; }
  #app-header #floor-nav {
    grid-area: 2 / 1 / 3 / -1; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)) minmax(0,1.23fr);
    justify-content: stretch; gap: 0; overflow: visible; border-top: 1px solid #8b947828;
  }
  #app-header #floor-nav a:has(>small) {
    align-items: center; text-align: center; width: 100%; min-width: 0; min-height: 39px;
    padding: 3px 0; font-size: clamp(.62rem,2.8vw,.83rem); line-height: 1.1; white-space: normal;
  }
  #app-header #floor-nav a > small { font-size: .55rem; letter-spacing: .04em; white-space: nowrap; }
  #hall-utilities #scores-nav, #hall-utilities #return-room, #hall-utilities #account-button {
    padding: 4px 6px; min-height: 36px; font-size: .78rem;
  }
}
@media(max-width:370px) {
  #app-header .brand { font-size: .92rem; gap: 3px; }
  #app-header .brand img { width: 24px; height: 24px; }
  #hall-utilities #scores-nav, #hall-utilities #return-room, #hall-utilities #account-button { padding-inline: 4px; }
}
@media(max-width:899px){
  #hall-utilities #master-switch{min-height:32px;padding:3px 6px;font-size:.76rem}
}

/* The game owns the space between the fixed header and footer. Opening a
   panel never rebuilds the board or its media player. */
body.active-play #main { flex: 1; min-width: 0; min-height: 0; width: 100%; max-width: none; margin: 0; padding: 0; }
body.active-play #online { flex: 1; min-height: 0; height: 100%; }
body.active-play #room-layout.with-company {
  --info-width: 0px; --crew-width: 0px; --panel-dock-width: clamp(246px,23vw,340px);
  position: relative; isolation: isolate; display: grid;
  grid-template-columns: minmax(0,1fr) var(--info-width) var(--crew-width);
  grid-template-rows: minmax(0,1fr); gap: 0; align-items: stretch;
  width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; overflow: hidden;
  background: radial-gradient(ellipse at 52% 22%,#3144385c,transparent 68%),linear-gradient(115deg,#17271edb,#132019ee),url('/materials/felt.webp') center/320px;
}
body.active-play #room-layout.info-docked { --info-width: var(--panel-dock-width); }
body.active-play #room-layout.crew-docked { --crew-width: var(--panel-dock-width); }
body.active-play #play-area {
  display: block; grid-area: 1/1; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: clip; overscroll-behavior: contain;
}
body.active-play #room.in-game { display: flex; height: 100%; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
body.active-play #room .cabinet-playfield {
  flex: 1; min-width:0; min-height: 0; padding:clamp(2px,.55vmin,8px); border: 0; border-radius: 0; box-shadow: none; overflow: clip; background: transparent;
}
body.active-play #room .game-deck { min-width: 0; min-height: 0; }
body.active-play #room .game-deck:has(> .retro-cabinet),
body.active-play #room .game-deck:has(> .table-game) { container-type: size; }
body.active-play #room .retro-cabinet { width: min(100%,max(270px,calc((100cqh - 128px)*1.8))); max-width: none; }
body.active-play #room .table-game { width: 100%; max-width: none; }
body.active-play #room .table-game :is(.checkered-board,.map-board) {
  width: min(100%,max(160px,calc(100cqh - 72px))); max-width: none;
}
body.active-play #room .table-game:has([data-board-roll]) .map-board { width: min(100%,max(160px,calc(100cqh - 126px))); }
body.active-play #room .table-game .table-meta { width: fit-content; max-width: 100%; margin-inline: auto; gap: 12px; }
body.active-play #room .table-game .table-controls:not(:has(button,.board-dice)) { margin: 0; min-height: 0; }
body.active-play #room .backgammon-board { width: min(100%,1150px); margin-inline: auto; }
body.active-play #room .match { width: min(100%,72dvh); max-width: none; }
body.active-play #room .stribe-board { width: min(100%,89dvh); max-width: none; }
body.active-play #room .game-visual[data-kind=dart], body.active-play #room .dart-targets,
body.active-play #room .game-visual[data-kind=bowling], body.active-play #room .bowl-controls {
  width: min(100%,1050px); margin-inline: auto;
}
#view-winners{position:fixed;z-index:12;top:calc(var(--header-height,64px) + 10px);right:max(12px,env(safe-area-inset-right));min-height:38px;padding:7px 13px;background:var(--glass-light);color:#162b22;border:1px solid #a4c9b0;box-shadow:var(--glaze-shadow)}
#match-result-dialog[data-outcome]{
  box-sizing:border-box;position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;
  padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  border:0;background:transparent;box-shadow:none;backdrop-filter:none;transform:none;overflow:clip;color:#f4ebda
}
#match-result-dialog[data-outcome][open]{display:grid;place-items:center;animation:none}
#match-result-dialog[data-outcome]::backdrop{background:#1017139e;backdrop-filter:none;animation:none}
@media(prefers-reduced-transparency:reduce){#match-result-dialog[data-outcome]::backdrop{background:#111e19ed}}
#match-confetti{
  position:absolute;z-index:0;inset:var(--header-height,0px) 0 var(--status-height,0px);
  overflow:clip;pointer-events:none
}
#match-confetti>i{position:absolute;left:0;top:0;border-radius:1px;box-shadow:inset 1px 1px #fff4,inset -1px -1px #39231429}
#match-confetti>i:nth-child(6n){border-radius:55% 15%}
#match-result-dialog .ceremony-frame{
  display:block;box-sizing:border-box;position:relative;z-index:1;width:min(500px,100%);min-height:0;max-height:100%;
  overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;
  border:1px solid #b09a71;border-radius:12px;
  background:linear-gradient(160deg,#233e34f0,#172922f4),var(--mat-felt) center/300px;
  box-shadow:inset 0 1px #f2d19690,inset 0 0 0 3px #405344,0 12px 38px #090d1099
}
.ceremony-top{
  position:relative;display:flex;align-items:center;justify-content:space-between;gap:12px;
  margin:0 5px;padding:5px clamp(9px,3vw,19px);border-bottom:1px solid #96a98e40;
  color:#dae2cf;font:650 .82rem/1.3 system-ui,sans-serif
}
#match-result-dialog .ceremony-dismiss{
  flex:none;min-height:36px;padding:4px 6px;gap:6px;white-space:nowrap;
  border:0;background:transparent;color:#eee7d6;box-shadow:none;font-size:.83rem
}
#match-result-dialog .ceremony-dismiss i{font:400 1.25rem/1 system-ui,sans-serif}
.ceremony-hero{text-align:center;padding:16px clamp(13px,4vw,32px) 17px}
#ceremony-outcome{margin:0 0 1px;color:#ebd7a9;font:750 .83rem/1.4 system-ui,sans-serif;letter-spacing:.045em}
#match-result-title{
  overflow-wrap:anywhere;text-wrap:balance;margin:0;color:#f6dda4;
  font:400 clamp(2rem,5.6vw,3.35rem)/1.04 "STIX Two Text",Georgia,serif;
  letter-spacing:-.025em;text-shadow:0 1px #120f0d,0 2px 1px #0f1c17
}
#match-result-title:focus{outline:none}
.ceremony-detail{margin:4px 0 0;color:#d4ded3;font-size:.84rem}
.ceremony-seal{position:relative;width:74px;height:68px;margin:0 auto 5px}
.ceremony-ribbon::before,.ceremony-ribbon::after{
  content:'';position:absolute;z-index:0;top:31px;left:20px;width:17px;height:36px;transform:rotate(22deg);
  clip-path:polygon(0 0,100% 0,100% 100%,50% 81%,0 100%);
  background:linear-gradient(90deg,#461f29 8%,#ba8f53 9% 15%,#873d47 16% 80%,#b98c55 81% 86%,#5c2b35 87%)
}
.ceremony-ribbon::after{left:38px;transform:rotate(-22deg)}
.ceremony-medal{
  position:absolute;z-index:1;top:0;left:9px;width:56px;height:56px;border-radius:50%;
  display:grid;place-items:center;border:1px solid #ecd199;
  background:repeating-conic-gradient(from 4deg,#b5864d 0deg 4deg,#f0d292 4deg 6deg,#926935 6deg 8deg);
  box-shadow:inset 0 1px #fff2c5,0 2px 2px #0c1b16c4
}
.ceremony-medal::before{
  content:'';position:absolute;inset:4px;border-radius:50%;border:1px solid #795a31;
  background:linear-gradient(145deg,#f2dfa7 8%,#d7b271 40%,#bb8f54 73%,#ead19a);
  box-shadow:inset 0 0 0 1px #f9e5b5,inset 0 0 0 3px #ba9559
}
.ceremony-cup{position:relative;width:24px;height:24px;filter:drop-shadow(0 1px .2px #fce8b7)}
.ceremony-cup::before,.ceremony-cup::after{
  content:'';position:absolute;top:3px;width:7px;height:6px;border:2px solid #71502c;border-radius:2px 2px 5px 5px
}
.ceremony-cup::before{left:-1px}.ceremony-cup::after{right:-1px}
.ceremony-cup b{
  position:absolute;z-index:1;top:1px;left:4px;width:16px;height:15px;border-radius:1px 1px 8px 8px;
  border-top:2px solid #5c442c;background:linear-gradient(105deg,#63492b,#9c743b 40%,#64482b)
}
.ceremony-cup b::before,.ceremony-cup b::after{content:'';position:absolute;background:#6a4c2a}
.ceremony-cup b::before{top:12px;left:7px;width:3px;height:6px}.ceremony-cup b::after{top:17px;left:3px;width:11px;height:3px;border-radius:2px 2px 0 0}
.ceremony-flecks{display:none;position:absolute;inset:0;pointer-events:none}
.ceremony-flecks i{position:absolute;width:5px;height:9px;border-radius:1px;background:#ddba70}
.ceremony-flecks i:nth-child(1){left:-19px;top:10px;transform:rotate(-31deg)}
.ceremony-flecks i:nth-child(2){left:-4px;top:37px;height:5px;background:#b75a61;transform:rotate(21deg)}
.ceremony-flecks i:nth-child(3){left:-28px;top:45px;height:4px;background:#f0e2be;transform:rotate(-13deg)}
.ceremony-flecks i:nth-child(4){right:-18px;top:3px;background:#b75a61;transform:rotate(35deg)}
.ceremony-flecks i:nth-child(5){right:-8px;top:33px;background:#eedfba;transform:rotate(-15deg)}
.ceremony-flecks i:nth-child(6){right:-31px;top:45px;height:5px;transform:rotate(22deg)}
@media(prefers-reduced-motion:reduce){.ceremony-flecks{display:block}}
:root[data-graphics=low] .ceremony-flecks{display:block}
#match-result-dialog:is([data-outcome=draw],[data-outcome=house],[data-outcome=none]) #match-result-title{color:#e7e5d6}
.ceremony-results{display:grid;gap:12px;padding:0 clamp(13px,4vw,27px) 18px}
.ceremony-ledger{
  min-width:0;padding:11px 15px 7px;color:#27362d;
  border:1px solid #e1cfa1;border-radius:3px;
  background:linear-gradient(108deg,#f4edda,#e9ddbd 76%,#eee3ca);
  box-shadow:inset 0 1px #fff7dc,0 2px 5px #0e17144d
}
.ceremony-ledger h3,#match-prize h3{
  margin:0 0 3px;color:#405244;font:700 .78rem/1.4 system-ui,sans-serif;letter-spacing:.045em
}
.ceremony-ledger h3{padding-bottom:5px;border-bottom:1px solid #b9b095}
.ceremony-ledger ol{list-style:none;margin:0;padding:0}
.ceremony-ledger li{display:flex;justify-content:space-between;align-items:baseline;gap:10px;padding:5px 0;border-bottom:1px dotted #a59879}
.ceremony-ledger li:last-child{border:0}
.ceremony-player{min-width:0;overflow-wrap:anywhere;font:400 1.06rem/1.25 "STIX Two Text",Georgia,serif}
.ceremony-player small{display:inline-block;margin-left:3px;color:#4e5949;font:600 .72rem/1.15 system-ui,sans-serif}
.ceremony-row-seal{display:inline-block;margin-right:5px;color:#74541e;font:.85rem/1 Georgia,serif}
.ceremony-ledger li b{flex:none;color:#303c31;font:650 .9rem/1.25 system-ui,sans-serif;font-variant-numeric:tabular-nums}
#match-result-dialog .ceremony-night{position:static;padding:0;margin:0;border:0;border-radius:0;background:none;box-shadow:none}
.ceremony-details{min-width:0;margin:0;color:#e2e6d7;font-size:.85rem}
.ceremony-details summary{width:fit-content;cursor:pointer;min-height:34px;align-content:center;text-underline-offset:3px}
.ceremony-details summary:hover{text-decoration:underline}
.ceremony-details[open] summary{margin-bottom:3px}
.ceremony-details ul{margin:4px 0;padding-left:19px}
#match-prize{display:grid;justify-items:start;gap:4px;width:100%;min-width:0}
#match-prize h3{color:#e1dfc9}
#match-prize .reward-slip{width:100%;max-width:100%}
.ceremony-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
#match-result-dialog .ceremony-actions button{min-height:42px;padding:6px 14px}
#match-result-dialog .ceremony-actions button:first-child{
  color:#322819;border:1px solid #d7bc83;background:linear-gradient(#eedba7,#d8bc81);
  box-shadow:inset 0 1px #fff0c6,0 1px 2px #111a15
}
.ceremony-wait{margin:0;color:#c8d4c8;font-size:.84rem}
@media(max-height:510px){
  .ceremony-seal{transform:scale(.78);height:52px;margin-top:-5px;margin-bottom:1px;transform-origin:top center}
  .ceremony-hero{padding-block:8px 10px}
  #match-result-title{font-size:clamp(1.7rem,5vw,2.4rem)}
  .ceremony-results{gap:7px;padding-bottom:11px}
}
body.active-play #room .quiz-card { width: min(100%,900px); margin: auto; }
#quiz-countdown { color: #ffdda1; font-variant-numeric: tabular-nums; white-space: nowrap; }
body.active-play #play-area:has(> #quiz-media:not([hidden])) {
  display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); grid-template-rows: minmax(0,1fr);
  align-content: stretch; align-items: center; gap: clamp(7px,1.6vw,26px); padding: clamp(6px,1.6vw,24px);
}
body.active-play #play-area:has(> #quiz-media:not([hidden])) > #room { display: contents; }
body.active-play #play-area:has(> #quiz-media:not([hidden])) .cabinet-playfield { padding: 0; align-self: stretch; }
body.active-play #quiz-media { align-self: center; margin: 0; width: 100%; }
body.active-play #quiz-media :is(img,iframe) { display: block; width: 100%; max-height: calc(100dvh - var(--header-height) - var(--status-height) - 80px); object-fit: contain; }

/* A pinned panel has its own track. A floating panel leaves the game exactly
   where it was. On phones, the dock is below the board to preserve its width. */
body.active-play :is(#game-info-rail,#social-rail):not([hidden]) {
  position: absolute; z-index: 5; inset: 8px calc(var(--info-width) + var(--crew-width) + 8px) 8px auto;
  display: flex; flex-direction: column; gap: 9px; align-self: stretch; min-height: 0; height: auto;
  width: min(352px,calc(100% - 16px)); max-height: none; overflow: auto; overscroll-behavior: contain;
  padding: 10px; border: 1px solid #897e61; border-radius: 12px;
  background: var(--painted-steel,#25332d); color: #f3ead9; box-shadow: 0 7px 35px #040b08b0,inset 0 1px #e9ce9d52;
}
body.active-play #game-info-rail.is-docked:not([hidden]), body.active-play #social-rail.is-docked:not([hidden]) {
  position: relative; inset: auto; grid-row: 1; height: 100%; width: 100%; max-width: none;
  border-block: 0; border-right: 0; border-radius: 0; box-shadow: inset 1px 0 #d9bc8932;
}
body.active-play #game-info-rail.is-docked { grid-column: 2; }
body.active-play #social-rail.is-docked { grid-column: 3; }
.play-panel-head {
  flex: none; display: flex; align-items: center; gap: 5px; min-width: 0;
  padding-bottom: 7px; border-bottom: 1px solid #88917852;
}
.play-panel-title { flex: 1; font: 750 1.12rem/1.2 var(--condensed),sans-serif; margin: 0; }
.play-panel-head button, #play-panel-actions button {
  min-height: 36px; padding: 5px 10px; font-size: .82rem; line-height: 1.1; white-space: nowrap;
  color: #e8dfc6; background: linear-gradient(140deg,#39443b,#27332c); border: 1px solid #6b735f; box-shadow: inset 0 1px #f0d8a31c;
}
.play-panel-head [aria-pressed=true], #play-panel-actions [aria-expanded=true] { color: #ffe0a7; border-color: #c5a571; }
#info-body { min-width: 0; }
#info-body .room-head, #info-body .room-console { display: grid; gap: 8px; margin: 0; padding: 9px 3px; background: transparent; border: 0; }
#info-body .room-head { border-bottom: 1px solid #88917852; }
#info-body .room-head h2 { font-size: 1.45rem; }
#info-body .room-head .controls { flex-wrap: wrap; }
#info-body .room-head button, #info-body .room-console button { padding-inline: 8px; }
#info-body .room-standing { width: 100%; min-width: 0; }
body.active-play #social-rail .room-chat { min-height: 215px; }
body.active-play #social-rail #chat-messages { min-height: 65px; }
body.active-play #app-footer { gap: 5px clamp(6px,1vw,17px); padding-inline: max(8px,env(safe-area-inset-left)); }
body.active-play #app-footer :is(#connection-status,#account-status,#room-status) { display: none; }
body.active-play #app-footer #play-status:not(:empty) {
  display: block; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .86rem; color: #f0d5a3; font-weight: 650;
}
#play-panel-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; }
@media(max-width:899px) {
  body.active-play #room-layout.with-company {
    grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) var(--dock-height,0px); --info-width: 0px; --crew-width: 0px;
  }
  body.active-play #room-layout:is(.info-docked,.crew-docked) { --dock-height: clamp(126px,35dvh,290px); }
  body.active-play :is(#game-info-rail,#social-rail):not([hidden]) {
    inset: auto 6px 6px; width: auto; max-height: calc(100% - 12px);
  }
  body.active-play #game-info-rail.is-docked:not([hidden]), body.active-play #social-rail.is-docked:not([hidden]) {
    grid-area: 2 / 1; inset: auto; max-height: none; border: 0; border-top: 1px solid #a28860;
  }
  body.active-play #play-area:has(> #quiz-media:not([hidden])) {
    display: flex; flex-direction: column; align-items: stretch; justify-content: safe center; gap: 6px; padding: 4px;
  }
  body.active-play #play-area:has(> #quiz-media:not([hidden])) .cabinet-playfield { flex: none; overflow: visible; }
  body.active-play #quiz-media { max-width: 660px; }
  body.active-play #quiz-media :is(img,iframe) { max-height: 30dvh; }
  body.active-play #room .retro-cabinet { width: min(100%,max(220px,calc((100cqh - 92px)*1.8))); }
}
@media(max-width:600px) {
  body.active-play #app-footer { justify-content: center; row-gap: 2px; padding-top: 3px; }
  body.active-play #app-footer #play-status:not(:empty) { flex: 0 0 100%; line-height: 1.15; font-size: .72rem; text-align: center; }
  body.active-play #play-panel-actions { margin: 0; }
  body.active-play #app-footer button { min-height: 33px; padding: 4px 7px; font-size: .79rem; }
  body.active-play #room .cabinet-playfield { padding: 4px; }
  body.active-play #room .quiz-card { padding: 9px; }
}
body.active-play .play-panel-head {
  position: sticky; top: -10px; z-index: 2; margin: -10px -10px 0; padding: 8px 10px;
  background: #283730; box-shadow: 0 2px 4px #10191150;
}
#info-rules { padding: 4px 4px 12px; }
#info-rules h3 { font-size: 1rem; color: #ffdda1; }
#info-rules p, #info-rules dl { margin: .55rem 0; }
#info-rules dl > div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid #657061; }
#info-rules dd { margin: 0; }
#info-rules summary { cursor: pointer; color: #f4d18f; }
#info-body .controls button[aria-expanded=true] { border-color: #c5a571; color: #ffe0a7; }
body.active-play #room .quiz-card {
  box-shadow: 0 8px 28px #08140f72,inset 0 1px #ead5a040; border-color: #ad9467;
}
body.active-play #room .quiz-options .quiz-option { justify-content: flex-start; }
@media(min-width:700px) {
  body.active-play #room .quiz-card { padding: clamp(22px,3.2vw,52px); }
  body.active-play #room .quiz-card h3 { font-size: clamp(1.65rem,2.7vw,2.6rem); margin: clamp(18px,2.4vw,35px) 0; }
  body.active-play #room .quiz-options .quiz-option { min-height: 58px; padding: 12px 16px; }
}

/* Activity pages use the same fixed chrome as a crew game. */
body:is(.activity-screen,.table-screen) { height: 100dvh; min-height: 0; overflow: hidden; }
body:is(.activity-screen,.table-screen) #main {
  width: 100%; max-width: none; margin: 0; padding: 0; min-height: 0; flex: 1; display: flex;
}
body.activity-screen #public-page, body.table-screen #together {
  flex: 1; width: 100%; min-height: 0; padding: 0;
  display: grid; grid-template-rows: auto minmax(0,1fr) auto; background: #172820;
}
body.activity-screen .activity-bar, body.table-screen #tool-heading {
  position: relative; z-index: 3; min-width: 0; display: flex; gap: clamp(7px,1.3vw,20px);
  align-items: center; flex-wrap: wrap; margin: 0; padding: 3px max(8px,env(safe-area-inset-left)); min-height: 41px;
  border-bottom: 1px solid #69725c; background: var(--painted-steel,#27352e);
}
.activity-bar h1, body.table-screen #tool-heading h1 {
  flex: 1; margin: 0; font: 800 clamp(1rem,2vw,1.32rem)/1.07 var(--condensed); letter-spacing: .025em;
}
body.table-screen #tool-heading > div { flex: 1; }
body.table-screen #tool-floor { display: none; }
.activity-back, .activity-help summary, .activity-kit-toggle {
  display: inline-flex; align-items: center; justify-content: center; min-height: 33px; padding: 3px 7px;
  color: #eed6a4; font-size: .83rem; text-decoration: none; line-height: 1.15; cursor: pointer;
}
.activity-help summary, .activity-kit-toggle {
  border: 1px solid #747865; border-radius: 5px; background: #2a3831; list-style: none; box-shadow: inset 0 1px #ecd2aa26;
}
.activity-help summary::-webkit-details-marker { display: none; }
.activity-help > div, .activity-palette {
  position: absolute; z-index: 3; right: 6px; top: calc(100% + 4px); width: min(340px,calc(100% - 12px));
  border-radius: 9px; padding: 12px; background: var(--painted-steel,#27352e); border: 1px solid #968066;
  box-shadow: 0 8px 25px #0a130eb0; max-height: max(130px,46dvh); overflow: auto;
}
.activity-help p { margin: 0 0 7px; }
.activity-help p:last-child { margin: 0; }
.activity-help .room-mode { font-size: .83rem; }
.activity-palette { top: 4px; z-index: 2; }
.activity-bar .toy-tools { margin: 0; gap: 5px; }
.activity-bar .toy-tools button, .activity-bar .toy-tools select { min-height: 33px; padding: 4px 8px; font-size: .82rem; }
.activity-screen .lounge-message { margin: 0; padding: 3px 8px; }
.activity-screen .lounge-message:empty { display: none; }
body.activity-screen .hygge-room {
  position: relative; display: grid; place-items: center; container-type: size; width: 100%; height: 100%; max-width: none; min-height: 0;
  margin: 0; padding: clamp(3px,.6vw,9px); overflow: hidden; border: 0; border-radius: 0;
}
body.activity-screen .wb-frame {
  width: min(100cqw,calc(100cqh*1.6)); aspect-ratio: 1.6; max-height: 100%; margin: 0;
  overflow: hidden; border: 0; box-shadow: 0 0 0 3px #998568,0 3px 10px #0a170f80;
}
body.activity-screen .wb-frame :is(.draw-board,.board-preview) { width: 100%; height: 100%; aspect-ratio: 1.6; }
body.activity-screen .hygge-room.toy-table { padding: 0; }
body.activity-screen .toy-table .prop-stage {
  width: 100%; max-width: none; height: 100%; aspect-ratio: auto; margin: 0; padding: 0; border: 0; border-radius: 0;
}
body.activity-screen .prop-stage canvas { max-width: 100%; }
body.table-screen #together .local-tools {
  width: 100%; max-width: none; height: 100%; min-height: 0; margin: 0; overflow: auto;
}
body.table-screen .local-tool {
  display: flex; flex-direction: column; width: 100%; min-height: 100%; gap: 6px; border: 0; border-radius: 0;
  margin: 0; padding: clamp(5px,1vw,15px);
}
body.table-screen .local-tool:has(.tool-surface) { height: 100%; min-height: 0; }
.tool-surface { flex: 1; display: grid; place-items: center; min-height: 0; width: 100%; container-type: size; }
body.table-screen .local-tool .tool-controlbar { flex: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: end; gap: 5px 12px; }
body.table-screen .tool-controlbar label, body.table-screen .tool-controlbar p { margin: 0; max-width: 100%; }
body.table-screen .tool-controlbar button, body.table-screen .tool-controlbar select { min-height: 38px; }
body.table-screen .tool-controlbar p:not(:empty) { align-self: center; color: #efdaa9; font-variant-numeric: tabular-nums; }
body.table-screen #local-charge-hint { margin: 0; text-align: center; font-size: .78rem; }
body.table-screen #local-bottle-stage { width: min(100cqw,100cqh); height: auto; aspect-ratio: 1; margin: 0; }
body.table-screen #local-bottle-stage .seat { width: clamp(27px,6cqw,58px); height: auto; aspect-ratio: 1; font-size: clamp(.88rem,2.6cqw,1.6rem); }
body.table-screen #local-dice { display: grid; min-height: 0; width: 100%; height: 100%; }
body.table-screen #local-dice :is(.game-visual,.game-fallback,.dice-tray) { min-height: 0; width: 100%; height: 100%; margin: 0; }
body.table-screen #local-dice .game-visual.enhanced canvas { width: 100% !important; height: 100% !important; aspect-ratio: auto; }
body.table-screen #local-dice .dice-tray { display: flex; align-items: center; justify-content: center; color: #e8d9b9; }
body.table-screen .local-tool:is([data-tool=pointtavle],[data-tool=turur]) { justify-content: safe center; align-items: center; }
body.table-screen .local-tool[data-tool=pointtavle]{height:100%;min-height:0;container-type:size}
body.table-screen #manual-scores{width:min(100%,1100px);min-height:0;display:grid;gap:4px 12px;grid-template-columns:repeat(auto-fit,minmax(min(100%,270px),1fr));align-content:center;margin:0}
body.table-screen #manual-scores li{display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;gap:3px;padding:2px;min-width:0}
body.table-screen #manual-scores li :is(input,button,strong){width:auto;min-width:0;max-width:100%;min-height:32px;margin:0;padding:4px}
body.table-screen #manual-scores li input{width:100%}
body.table-screen #manual-scores li button{width:32px}
body.table-screen #manual-scores li strong{min-width:2.4ch;text-align:center}
@container (max-width:550px){#manual-scores:has(li:nth-child(8)) {grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}#manual-scores:has(li:nth-child(8)) li{grid-template: auto auto / 1fr auto 1fr}#manual-scores:has(li:nth-child(8)) li input{grid-column:1/-1}#manual-scores:has(li:nth-child(8)) li button{width:100%}}
@container (min-width:551px) and (max-height:380px){body.table-screen #manual-scores{grid-template-columns:repeat(3,minmax(0,1fr))}}
body.table-screen .local-tool[data-tool=turur] #turn-time { font-size: clamp(3rem,min(24vw,31dvh),12rem); }

/* Preserve playing-card proportions as seven columns grow to fill a table. */
body.active-play #room .game-deck:has(> .solitaire-table),
body.active-play #room .game-deck:has(> .slot-cabinet), body.table-screen #bonus-slot { container-type: size; }
body.active-play #room .solitaire-table {
  width: 100%; height: 100%; min-height: 0; margin: 0; padding: clamp(3px,1vw,13px);
  display: flex; flex-direction: column; align-items: center; gap: clamp(2px,.6vh,8px); overflow: auto;
}
body.active-play #room .solitaire-table .card-caption, body.active-play #room .solitaire-table .card-instruction { flex: none; min-height: 0; margin: 0; text-align: center; }
body.active-play #room .solitaire-scroll { width: 100%; min-height: 0; flex: 1; overflow: auto; padding: 4px; }
body.active-play #room .solitaire-board {
  --card-gap: clamp(3px,1cqw,14px); --card-width: max(15px, min(calc((100cqw - 48px - 6*var(--card-gap))/7),calc((100cqh - 110px)/4.15)));
  --card-height: calc(var(--card-width)*1.42); --fan-open: clamp(16px,calc(var(--card-height)*.24),40px); --fan-back: clamp(6px,calc(var(--card-height)*.085),17px);
  width: min(100%,calc(7*var(--card-width) + 6*var(--card-gap))); min-width: 0; max-width: none; margin: auto;
}
body.active-play #room .solitaire-board :is(.solitaire-top,.solitaire-columns) { gap: var(--card-gap); }
body.active-play #room .solitaire-board .solitaire-top { margin: 0 0 var(--card-gap); }
body.active-play #room .solitaire-board :is(.deck-card,.card-slot) { width: 100%; height: auto; min-height: 0; aspect-ratio: 1 / 1.42; }
body.active-play #room .solitaire-column { min-height: 0; height: calc(var(--card-height,86px) + var(--covered,0)*var(--fan-back,12px) + var(--shown,0)*var(--fan-open,44px)); }
body.active-play #room .solitaire-column > :is(.deck-card,.card-slot) { top: calc(var(--covered-offset,0)*var(--fan-back,12px) + var(--shown-offset,0)*var(--fan-open,44px)); }
body.active-play #room .solitaire-table > .controls { justify-content: center; }
body.table-screen [data-tool=bonus] { height: 100%; min-height: 0; }
body.table-screen #bonus-slot { display: flex; flex: 1; min-height: 0; align-items: safe center; justify-content: center; overflow: auto; }
:is(body.active-play #room,body.table-screen #bonus-slot) .slot-cabinet {
  container-type: inline-size; flex: none; width: min(100%,max(280px,calc((100cqh - 126px)*1.32))); max-width: none; margin: auto;
}
:is(body.active-play #room,body.table-screen #bonus-slot) .slot-dials { --cell: clamp(44px,13cqw,158px); }
:is(body.active-play #room,body.table-screen #bonus-slot) .slot-arm { width: clamp(38px,8cqw,77px); height: clamp(76px,16cqw,152px); }
:is(body.active-play #room,body.table-screen #bonus-slot) .slot-arm i { height: 69%; width: 15%; left: 44%; }
:is(body.active-play #room,body.table-screen #bonus-slot) .slot-arm i::before { width: clamp(22px,4cqw,40px); height: auto; aspect-ratio: 1; }
@media(max-width:600px) {
  .activity-bar { gap: 4px 7px; }
  .activity-bar h1 { font-size: 1rem; }
  .activity-back,.activity-help summary,.activity-kit-toggle { padding: 3px 5px; font-size: .75rem; }
  .activity-bar .toy-tools select { max-width: 115px; }
  body.table-screen .tool-controlbar { gap: 5px; }
  body.table-screen .tool-controlbar label { min-width: 0; font-size: .72rem; }
  body.table-screen .tool-controlbar select, body.table-screen .tool-controlbar button { max-width: 165px; min-height: 36px; font-size: .78rem; padding: 4px 6px; }
  body.table-screen .tool-controlbar p:not(:empty) { flex-basis: 100%; text-align: center; font-size: .83rem; }
  body.active-play #room .solitaire-board { --card-gap: 3px; --card-width: max(15px,min(calc((100cqw - 20px - 6*var(--card-gap))/7),calc((100cqh - 80px)/4.15))); }
}
body:is(.activity-screen,.table-screen) #app-footer { gap: 6px 10px; align-items: center; padding-inline: max(8px,env(safe-area-inset-left)); }
body:is(.activity-screen,.table-screen) #app-footer :is(#account-status,#room-status,#play-status) { display: none; }
body:is(.activity-screen,.table-screen) #connection-status { margin-right: auto; }
body:is(.activity-screen,.table-screen) #app-footer button { margin: 0; min-height: 36px; }
body.activity-screen .hygge-room.toy-table { display: flex; flex-direction: column; align-items: stretch; }
.prop-window { position: relative; flex: 1; container-type: size; min-height: 0; width: 100%; overflow: hidden; }
body.activity-screen .prop-window.magnified .prop-stage { width: max(100%,calc(100cqh*1.6)); }
.toy-view {
  flex: none; display: flex; justify-content: center; align-items: center; gap: 12px; padding: 4px 8px;
  border-top: 1px solid #747461; background: var(--painted-steel,#27352e);
}
.toy-view label { display: flex; flex: 1; max-width: 320px; align-items: center; gap: 7px; font-size: .78rem; }
.toy-view input { width: 100%; min-width: 0; min-height: 32px; padding: 0; accent-color: #cba66c; }
.toy-view button { flex: none; font-size: .78rem; min-height: 32px; padding: 4px 7px; }
@media(max-width:600px) {
  body.activity-screen .activity-bar { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; gap: 4px; }
  .activity-bar .toy-tools { flex-wrap: nowrap; }
  .activity-bar .toy-tools select { max-width: clamp(76px,24vw,110px); }
  .activity-bar h1 { overflow-wrap: anywhere; }
  body.active-play #room .solitaire-table { padding-inline: 0; }
  body.active-play #room .solitaire-table .solitaire-scroll { padding-inline: 1px; }
  body.active-play #room .solitaire-board { --card-width: max(15px,min(calc((100cqw - 8px - 6*var(--card-gap))/7),calc((100cqh - 80px)/4.15))); }
}
:is(body.active-play #room,body.table-screen #bonus-slot) .slot-controls .slot-pull:is(:enabled,:hover,:focus-visible) { color: #302313; }

.crew-guide{width:min(100%,70ch);margin:clamp(20px,4vw,45px) auto 18px;padding:12px 18px;border-top:1px solid #81785a74;color:#e3decc;line-height:1.5}
.crew-guide summary{cursor:pointer;font-weight:650;color:#f1e4c4}
.crew-guide p{margin:10px 0 0}
dialog[open]{border:1px solid #9f946d;border-radius:18px;box-shadow:0 20px 80px #06120bc4,inset 0 1px #e5debb42}
dialog[open]::backdrop{background:#091712a9}
@supports(backdrop-filter:blur(4px)){
  html:not([data-graphics=low]) dialog[open]::backdrop{backdrop-filter:blur(4px)}
}
@media(prefers-reduced-motion:no-preference){
  dialog[open]{animation:open-dialog .16s ease-out both}
  dialog[open]::backdrop{animation:fade-scrim .14s ease-out both}
  body.active-play :is(#game-info-rail,#social-rail):not(.is-docked,[hidden]){animation:open-rail .14s ease-out both}
  @keyframes open-dialog{from{opacity:0;transform:translateY(7px) scale(.986)}to{opacity:1;transform:none}}
  @keyframes fade-scrim{from{opacity:0}to{opacity:1}}
  @keyframes open-rail{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:none}}
}
@media(prefers-reduced-transparency:reduce){html dialog[open]::backdrop{backdrop-filter:none!important;background:#111e19ed}}

@media(min-width:580px) and (max-height:540px) and (orientation:landscape){
  body:is(.active-play,.activity-screen,.table-screen) #app-header{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto;min-height:0;column-gap:8px;padding:2px max(8px,env(safe-area-inset-left))}
  body:is(.active-play,.activity-screen,.table-screen) #app-header>.brand{grid-area:1/1}
  body:is(.active-play,.activity-screen,.table-screen) #app-header .brand img{width:26px;height:26px}
  body:is(.active-play,.activity-screen,.table-screen) #app-header .brand span{display:none}
  body:is(.active-play,.activity-screen,.table-screen) #app-header #floor-nav{grid-area:1/2;display:flex;align-items:center;justify-content:space-evenly;border:0;overflow:visible}
  body:is(.active-play,.activity-screen,.table-screen) #app-header #floor-nav a{width:auto;min-height:32px;padding:2px max(3px,.6vw);font-size:.77rem}
  body:is(.active-play,.activity-screen,.table-screen) #app-header #floor-nav small{display:none}
  body:is(.active-play,.activity-screen,.table-screen) #app-header #hall-utilities{grid-area:1/3}
  body:is(.active-play,.activity-screen,.table-screen) #hall-utilities :is(button,a){min-height:32px}
  body:is(.active-play,.activity-screen,.table-screen) #app-footer{min-height:0;padding-block:2px max(2px,env(safe-area-inset-bottom));flex-wrap:nowrap}
  body:is(.active-play,.activity-screen,.table-screen) #app-footer button{min-height:32px;padding-block:4px}
  body.active-play #room .cabinet-playfield{padding:2px}
  body.active-play #room-layout.with-company{--panel-dock-width:clamp(180px,28vw,250px);grid-template: minmax(0,1fr) / minmax(0,1fr) var(--info-width) var(--crew-width)}
  body.active-play #room-layout.with-company.info-docked{--info-width:var(--panel-dock-width)}
  body.active-play #room-layout.with-company.crew-docked{--crew-width:var(--panel-dock-width)}
  body.active-play #game-info-rail.is-docked:not([hidden]){grid-area:1 / 2}
  body.active-play #social-rail.is-docked:not([hidden]){grid-area:1 / 3}
}

/* A rotated bottle fits inside its circular tray at every angle. */
body.table-screen #local-bottle-stage { container-type:inline-size; }
body.table-screen #local-bottle-stage .seat { width:clamp(17px,15cqw,58px);font-size:clamp(.75rem,5.5cqw,1.6rem); }
body.table-screen #local-bottle-stage #bottle { inset:17% 30%; pointer-events:none; }
body.table-screen #local-bottle-stage #bottle::before { inset:0; }

body.table-screen .local-tool[data-tool=pointtavle] { container:score-table / size; }
body.table-screen .local-tool[data-tool=pointtavle] > .controls { flex:none; }
@container score-table (max-width:550px) and (max-height:530px) {
  body.table-screen #manual-scores:has(li:nth-child(8)) { gap:2px 5px; }
  body.table-screen #manual-scores:has(li:nth-child(8)) li { padding:1px; gap:1px; }
  body.table-screen #manual-scores:has(li:nth-child(8)) li input { min-height:23px; height:23px; padding:1px 4px; font-size:.79rem; line-height:1.1; }
  body.table-screen #manual-scores:has(li:nth-child(8)) li :is(button,strong) { min-height:25px; height:25px; padding:0 3px; font-size:1rem; line-height:1.1; }
}
@media (orientation:landscape) and (max-height:510px) {
  body.table-screen .local-tool[data-tool=turur] {
    height:100%;min-height:0;container:turn-clock / size; display:grid;gap:5px 14px;justify-items:center;
    grid-template-areas:"setup time" "controls time";grid-template-columns:minmax(0,1fr) minmax(0,1.4fr);grid-template-rows:1fr 1fr;
  }
  body.table-screen .local-tool[data-tool=turur] > label { grid-area:setup;align-self:end;margin:0; }
  body.table-screen .local-tool[data-tool=turur] > .controls { grid-area:controls;align-self:start;margin:0; }
  body.table-screen .local-tool[data-tool=turur] > #turn-time {
    grid-area:time;margin:0;font-size:clamp(2.2rem,min(15cqw,52cqh),8rem);line-height:1.24;
  }
}
