/* Tabletop Refresh v2.1. Existing components, artwork and game state remain authoritative. */
.wrap{
 --tt-surface:#fff6e1;--tt-panel:#fffdf7;--tt-ink:#19376b;--tt-line:#b4c5da;
 --tt-slot:#eff5f9;--tt-warn:#ffedf2;--tt-warn-ink:#a71b41;
 --tt-weave:repeating-linear-gradient(90deg,#ed2450 0 12px,#f5a52b 12px 24px,#f5d43d 24px 36px,#239c64 36px 48px,#18b3b3 48px 60px,#225ba6 60px 72px,#834391 72px 84px);
 border-width:14px;
 background: url("/brand/paper-flecks.svg") repeat padding-box,
 linear-gradient(var(--tt-surface),var(--tt-surface)) padding-box,
 repeating-linear-gradient(0deg,transparent 0 3px,rgba(25,55,107,.18) 3px 4px) border-box,
 var(--tt-weave) border-box;
 background-size:240px 240px,auto,auto,auto;
}
.wrap::before,.wrap::after{display:none}
.wrap>header.top.game-header{padding-top:4px}
#room.tabletop-playing:not(.hidden){
 display:grid;grid-template-columns:minmax(0,1fr);align-items:start;gap:12px;
}
#room.tabletop-playing>.panel:first-child{
 margin:0;min-width:0;padding:12px;background:var(--tt-panel);border-color:var(--tt-line);
}
#room.tabletop-playing #players{grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr));gap:7px}
#room.tabletop-playing .player{background:var(--tt-panel);border-color:var(--tt-line);overflow:visible}
#room.tabletop-playing .player.mine{background:#e1f2d6;border-color:#82ae86}
#room.tabletop-playing .player strong{font-size:.85rem}
#room.tabletop-playing .player small{font-size:.67rem}
#room.tabletop-playing .player .avatar{width:38px;min-width:38px;height:47px;flex-basis:38px}
#room.tabletop-playing .room-controls{align-items:stretch}
#room.tabletop-playing .room-controls .chip{white-space:normal;overflow-wrap:anywhere}
.tabletop-progress{margin:10px 0;padding:10px 8px;border:1px solid var(--tt-line);border-radius:10px;text-align:center;background:var(--tt-panel)}
.tabletop-progress-label,.tabletop-scores-label{font:800 .78rem/1.25 var(--ui);color:var(--tt-ink);margin:0 0 6px}
.tabletop-round{display:block;font:400 1.35rem/1.1 var(--display);color:var(--tt-ink)}
.tabletop-turn{display:block;font:800 .72rem/1.35 var(--ui);margin:5px 0;color:var(--tt-ink)}
.tabletop-dots{display:grid;grid-template-columns:repeat(10,minmax(0,1fr));gap:4px;max-width:210px;margin:7px auto 0}
.tabletop-dots span{aspect-ratio:1;border-radius:50%;background:#d2dce7;border:1px solid #a8b9cf}
.tabletop-dots span.current{background:#ed2450;border-color:#a71b41}
.tabletop-dots span.past{background:#239c64;border-color:#167342}
#room.tabletop-playing #table{min-width:0}
#room.tabletop-playing #rows{gap:7px}
#room.tabletop-playing .rowline:not(.urgent):not(.preview-row):not(.preview-overflow):not(.chooseable):not(.drag-valid):not(.drag-invalid):not(.drag-low){background:var(--tt-panel);border-color:var(--tt-line)}
#room.tabletop-playing .rowline .cards{max-width:none}
#room.tabletop-playing .rowline .rowlabel{background:var(--tt-panel);color:var(--tt-ink);border-color:var(--tt-line)}
#room.tabletop-playing .empty-card:not(.predicted-slot){background:var(--tt-slot);border-color:#b6c9df}
#room.tabletop-playing .sixth-slot:not(.active){background:var(--tt-warn);color:var(--tt-warn-ink);border-color:#e5a1b3}
#room.tabletop-playing #hand{height:auto;min-height:125px;gap:6px;justify-content:safe center;overflow-x:auto;overflow-y:hidden;padding:24px 6px 12px}
#room.tabletop-playing #hand .gamecard{margin-left:0;transform:none;flex:0 0 clamp(60px,6vw,88px)}
#room.tabletop-playing #hand .gamecard.selected{transform:translateY(-9px);outline:2px solid #239c64;outline-offset:1px}
#room.tabletop-playing #table>.panel:has(#hand){background:var(--tt-panel);border-color:var(--tt-line)}
#room.tabletop-playing #table>.status-pill{background:#dcefeb;color:#125f68;border-color:#9dcac7}
#room.tabletop-playing #table>.status-pill #explain{color:#255f65}
@media(min-width:1100px){
 #room.tabletop-playing:not(.hidden){grid-template-columns:minmax(230px,24%) minmax(0,1fr)}
 #room.tabletop-playing #players{grid-template-columns:minmax(0,1fr)}
 #room.tabletop-playing .room-controls button{white-space:normal;max-width:100%}
}
@media(max-width:600px){
 .wrap{border-width:6px;padding:10px 5px 16px}
 #room.tabletop-playing>.panel:first-child{padding:9px}
 #room.tabletop-playing #players{grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr))}
 #room.tabletop-playing #table>.status-pill{flex-wrap:wrap}
 #room.tabletop-playing #table>.status-pill #play{flex:1 1 100%}
 #room.tabletop-playing #hand{justify-content:flex-start}
}
/* Preserve existing explicit theme selectors when present; cards retain their own penalty colors. */
html[data-theme="dark"] .wrap,html.dark .wrap,body.dark .wrap,body.dark-mode .wrap{
 --tt-surface:#202d42;--tt-panel:#29394f;--tt-ink:#f7ecd8;--tt-line:#61738b;
 --tt-slot:#1b293e;--tt-warn:#4a2639;--tt-warn-ink:#ffb6ca;
}
html[data-theme="dark"] #room.tabletop-playing .player,html.dark #room.tabletop-playing .player,body.dark #room.tabletop-playing .player,body.dark-mode #room.tabletop-playing .player{color:#f7ecd8}
html[data-theme="dark"] #room.tabletop-playing .player.mine,html.dark #room.tabletop-playing .player.mine,body.dark #room.tabletop-playing .player.mine,body.dark-mode #room.tabletop-playing .player.mine{background:#365441}
@media(prefers-reduced-motion:reduce){#room.tabletop-playing #hand .gamecard{transition:none}}

/* Theme is shared by the full game, not just the active tabletop. Preserve card colors. */
html[data-theme="dark"]{color-scheme:dark;--navy:#e9effb;--cream:#202d42;--paper:#29394f;--outline:#61738b;--blue:#9ad5ff;--red:#ff95b0}
html[data-theme="dark"] body{background:#121b29;color:#e9effb}
html[data-theme="dark"] :is(.panel,.settings-dialog,.action-dialog,.hybrid-modal-panel,.mode-card,.player,.waiting-players,.text-size-menu){background:#29394f;color:#f7ecd8;border-color:#61738b}
html[data-theme="dark"] :is(button:not(.gamecard):not(.primary),input,select,.game-toolbar .tool-button){background:#35465e;color:#f7ecd8;border-color:#8295ae}
html[data-theme="dark"] button.primary{background:#bd1741;color:#fff;border-color:#ffb4c6;box-shadow:none}
html[data-theme="dark"] :is(.muted,#roomHelp,.player small,.settings-note,.setting-toggle small,#table>.tag,#table>.tag span){color:#d0dcec}
html[data-theme="dark"] :is(.tag,.label,.header-brand .tag){color:#ffb0c4}
html[data-theme="dark"] .player.mine{background:#365441;color:#f7ecd8}
html[data-theme="dark"] .brand-lockup{filter:drop-shadow(0 0 1px #fff8e1)}
html[data-theme="dark"] #table>.status-pill{background:#214a4f;color:#d8fbf3;border-color:#719e9e}
html[data-theme="dark"] #room.tabletop-playing #table>.status-pill #explain{color:#d0eae5}
html[data-theme="dark"] .rowline .rowlabel{background:#29394f;color:#f7ecd8;border-color:#61738b}
html[data-theme="dark"] .rowline,.rowline{min-width:0}
html[data-theme="dark"] .rowline:not(.urgent):not(.preview-row):not(.preview-overflow):not(.chooseable):not(.drag-valid):not(.drag-invalid):not(.drag-low){background:#29394f}
html[data-theme="dark"] .rowline.urgent,html[data-theme="dark"] .rowline.preview-overflow,html[data-theme="dark"] .rowline.drag-invalid{background:#4a2639;border-color:#f29bb4}
html[data-theme="dark"] .rowline.preview-row,html[data-theme="dark"] .rowline.drag-valid{background:#21415e;border-color:#89c8f0}
html[data-theme="dark"] :is(.rowline.chooseable,.rowline.drag-low,#choice){background:#51401f;color:#fff0bb;border-color:#d8b75a}
html[data-theme="dark"] #choiceButtons .row-choice-button small{color:#d0dcec}
html[data-theme="dark"] .empty-card:not(.predicted-slot){background:#1b293e;border-color:#61738b}
html[data-theme="dark"] .sixth-slot{background:#4a2639;color:#ffb6ca;border-color:#e5a1b3}
html[data-theme="dark"] .sixth-slot.active{background:#712c47;color:#fff0f4}
html[data-theme="dark"] .gamecard{--navy:#19376b;--outline:#bfd0e6}
html[data-theme="dark"] :is(.result-player,.award-note,.result-details,.reveal-card,.chip){background:#35465e;color:#f7ecd8;border-color:#8295ae}
html[data-theme="dark"] :is(.result-player small,.result-score,.award-copy){color:#dce8f7}
html[data-theme="dark"] :is(.vector-heading,.hand-heading){filter:drop-shadow(0 0 1px #fff8e1)}
@media(max-width:1099px){
 #room.tabletop-playing #players{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))}
}
@media(max-width:600px){
 #room.tabletop-playing .player strong{font-size:.85rem}
 #room.tabletop-playing .player small{font-size:.68rem}
 #room.tabletop-playing .rowline .cards{grid-template-columns:repeat(6,minmax(37px,1fr));overflow-x:auto;overflow-y:hidden;padding:3px}
 #room.tabletop-playing .rowline{grid-template-columns:minmax(54px,72px) minmax(0,1fr)}
 #room.tabletop-playing .rowline .sixth-slot{overflow-wrap:anywhere}
}

/* Keep inset settings and reveal overlays legible in both palettes. */
.setting-toggle{flex-wrap:wrap}
.setting-toggle>span{flex:1 1 145px;min-width:0}
.setting-toggle select{flex:1 1 150px;width:auto;min-width:0;max-width:100%}
html[data-theme="dark"] :is(.setting-toggle,.reveal-strip,.rules .section-disclosure>summary){background:#29394f;color:#f7ecd8;border-color:#61738b}
html[data-theme="dark"] .rules .section-disclosure>summary:hover{background:#35465e}
html[data-theme="dark"] .reveal-number{background:#fffdf7;color:#19376b;border-color:#b4c5da}
html[data-theme="dark"] .result-player.own{background:#365441;border-color:#82ae86}
html[data-theme="dark"] .text-size-menu button small{color:#d0dcec}
html[data-theme="dark"] .text-size-menu button[aria-pressed="true"]{background:#51401f;color:#fff0bb;border-color:#d8b75a}
html[data-theme="dark"] .gamecard .card-points{background:#fff;color:inherit}
html[data-theme="dark"] .gamecard.tier-7 .card-points{color:#9d123a}
@media(max-width:600px){
 #room.tabletop-playing .rowline .cards{grid-template-columns:repeat(6,minmax(50px,1fr));scrollbar-width:thin}
 #room.tabletop-playing .rowline .gamecard .card-points{font-size:10px}
 #room.tabletop-playing .rowline .sixth-slot,#room.tabletop-playing .rowline .sixth-slot span{font-size:10px}
 #room.tabletop-playing .rowline .rowlabel .row-name,#room.tabletop-playing .rowline .rowlabel .row-score{font-size:11px}
}

/* On narrow portrait screens, put row metadata above the six slots so the
   warning and card numbers have the full width, not six squeezed columns. */
@media(max-width:600px){
 #room.tabletop-playing .rowline{grid-template-columns:minmax(0,1fr);gap:4px}
 #room.tabletop-playing .rowline .rowlabel{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:24px;padding:4px 7px}
 #room.tabletop-playing .rowline .rowlabel .row-name,#room.tabletop-playing .rowline .rowlabel .row-score{font-size:12px}
 #room.tabletop-playing .rowline .cards{grid-template-columns:repeat(6,minmax(44px,1fr));gap:3px}
}

/* Playtest feedback: keep the entire hand visible, without reducing type. */
#room.tabletop-playing #hand{display:flex;flex-wrap:wrap;justify-content:flex-start;align-content:start;align-items:flex-end;min-height:0;height:auto;overflow:visible;padding:12px 6px 6px;row-gap:14px}
#room.tabletop-playing #hand .gamecard{flex:0 0 clamp(70px,6vw,88px);min-width:0}
#room.tabletop-playing #table>.panel:has(#hand) .top{flex-wrap:wrap;gap:6px}
#room.tabletop-playing #table>.status-pill{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start}
#room.tabletop-playing #table>.status-pill .status-copy{min-width:0;overflow-wrap:break-word}
#room.tabletop-playing #table>.status-pill #play{white-space:nowrap;max-width:100%}
@media(max-width:800px){#room.tabletop-playing #table>.status-pill{grid-template-columns:minmax(0,1fr)}}

/* Desktop: the board and sidebar share the upper band; hand and history span both.
   Flatten only the non-semantic table wrapper, leaving its controls in DOM order. */
@media(min-width:1100px){
 #room.tabletop-playing:not(.hidden){grid-template-rows:auto auto auto auto auto auto;column-gap:12px;row-gap:8px}
 #room.tabletop-playing>#table:not(.hidden){display:contents}
 #room.tabletop-playing>.panel:first-child{grid-column:1;grid-row:1/5;align-self:start}
 #room.tabletop-playing #table>.tag{grid-column:2;grid-row:1;margin:0}
 #room.tabletop-playing .board-cost-note{grid-column:2;grid-row:2;margin:0}
 #room.tabletop-playing #rows{grid-column:2;grid-row:3}
 #room.tabletop-playing #table>.status-pill{grid-column:2;grid-row:4}
 #room.tabletop-playing #choice:not(.hidden){grid-column:1/-1;grid-row:5;margin:0}
 #room.tabletop-playing #table>.panel:has(#hand){grid-column:1/-1;grid-row:6}
 #room.tabletop-playing #table>.panel:has(#log){grid-column:1/-1;grid-row:7;margin:0}
 #room.tabletop-playing #hand{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,88px),1fr));gap:8px;justify-items:center;padding:12px 5px 4px}
 #room.tabletop-playing #hand .gamecard{width:min(100%,110px);max-width:110px}
 .wrap:has(#room.tabletop-playing:not(.hidden)) :is(#gameRules,#credits){width:100%;max-width:none;margin-inline:0}
}
