/* Explicit optional mode content; never silently mixed into a new base match. */
.optional-packs{border:1px solid #79624466;border-radius:10px;margin:12px 0;padding:10px 14px;color:#dfd0ac}
.optional-packs legend{padding:0 6px;font-size:.85rem}
.optional-packs label{display:flex;align-items:flex-start;gap:10px;cursor:pointer;line-height:1.5}
.optional-packs input{margin-top:5px;accent-color:#d4ad65}
.optional-packs small{display:block;color:#afa48e;font-size:.77rem}

.hero-search{display:flex;gap:12px;align-items:center;flex-wrap:wrap;color:#bfb399;font-size:.8rem;margin:12px 0}
.hero-search input{flex:1;min-width:180px;padding:9px 12px;color:#f0dfb9;background:#161b20;border:1px solid #7b6649;border-radius:6px}

/* One viewport, three tabletop bands: opponents / played cards / player. */
.sgs-table { height:100svh; height:100dvh; min-height:0; max-height:100dvh; grid-template-rows:auto auto minmax(0,1fr); overflow:hidden; color:var(--paper); }
.sgs-table .table-chrome { min-height:52px; padding:4px 12px; gap:8px; z-index:10; }
.sgs-table .chrome-right .btn { min-height:44px; padding:6px 12px; }
.sgs-table .seat-order-status { display:flex; align-items:center; gap:8px; margin:0; padding:3px 12px; min-width:0; overflow-x:auto; color:#d8d8bd; font-size:12px; white-space:nowrap; }
.seat-order-status > small { display:none; }
.seat-order-status .card-status-flags { display:flex; gap:6px; }
.battle-board { display:grid; grid-template-rows:180px minmax(70px,1fr) minmax(240px,38%); gap:8px; width:100%; min-width:0; min-height:0; margin:0; padding:8px 12px; color:var(--paper); }
.battle-arena { display:contents; }
.opponent-row { display:flex; justify-content:center; gap:12px; min-width:0; min-height:0; }
.opponent-panel,.self-panel,.play-area { border:1px solid #8f7d48; border-radius:10px; background:linear-gradient(135deg,#214d39,#142d24); min-width:0; min-height:0; }
.opponent-panel { flex:1; max-width:620px; padding:8px; display:grid; grid-template-columns:minmax(0,1fr) 110px; grid-template-rows:22px minmax(0,1fr); gap:4px 8px; }
.board-panel-heading { display:flex; justify-content:space-between; align-items:center; gap:6px; color:#e3cc8c; margin:0; font-size:12px; }
.board-panel-heading h2,.play-area h2 { margin:0; font-size:13px; font-weight:600; }
.opponent-panel .board-panel-heading { grid-column:1/-1; }
.battle-board .general-seat { display:grid; grid-template-columns:110px minmax(0,1fr); grid-template-rows:auto 44px; align-items:start; gap:4px 8px; min-width:0; max-width:none; }
.battle-board .general-seat .portrait { display:flex; gap:6px; align-items:center; grid-column:1; grid-row:1; min-width:0; text-align:left; }
.battle-board .general-seat .portrait-frame { width:46px; flex-shrink:0; border-width:2px; margin:0; }
.battle-board .general-seat .portrait-art { height:54px; }
.battle-board .general-seat .portrait-banner { font-size:11px; padding:2px 0; }
.battle-board .general-seat .hp-peaches { display:none; }
.battle-board .general-seat .seat-meta { margin:0; padding:0; min-width:0; }
.battle-board .general-seat .seat-nick { font-size:12px; }
.battle-board .general-seat .seat-nick small { display:none; }
.battle-board .general-seat .hp-text { font-size:18px; margin:2px 0; color:#ffb6ad; }
.battle-board .general-seat .skill-tag { font-size:11px; padding:2px; max-width:100%; white-space:normal; }
.battle-board .general-seat .mark-row { gap:2px; justify-content:flex-start; max-height:24px; overflow:auto; }
.battle-board .general-seat .equip-rail { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-row:1/3; grid-column:2; gap:4px; width:auto; min-width:0; }
.battle-board .equipment-slot { width:100%; min-width:0; }
.battle-board .equipment-slot__summary { min-height:44px; padding:3px 5px; gap:4px; }
.battle-board .equipment-slot__art { width:24px; height:28px; flex-basis:24px; }
.battle-board .equipment-slot__label { font-size:10px; }
.battle-board .equipment-slot__name { font-size:12px; line-height:1.3; white-space:normal; }
.battle-board .equipment-slot__stat { font-size:10px; }
.battle-board .equipment-slot__info { display:none; }
.battle-board .general-seat .opp-hands { position:static; grid-column:1; grid-row:2; padding:0; min-height:0; gap:0; justify-content:start; align-self:end; pointer-events:none; }
.battle-board .general-seat .opp-hands .back { display:none; }
.battle-board .general-seat .hand-count-badge { position:static; font-size:11px; margin:0; padding:1px 4px; }
.general-seat > .table-inspector { grid-row:2; grid-column:1; align-self:start; }
.general-seat.opponent > .table-inspector { transform:translateY(-8px); }
.general-seat.opponent > .table-inspector > summary { min-height:44px; font-size:11px; padding:3px; }
.table-inspector { min-width:0; }
.table-inspector > summary { display:flex; align-items:center; justify-content:center; min-height:44px; padding:6px; border:1px solid #b8a76c80; border-radius:6px; color:#e9d59c; background:#0a221bb3; font-size:12px; cursor:pointer; list-style:none; }
.table-inspector > summary::-webkit-details-marker { display:none; }
.table-inspector > summary:focus-visible { outline:3px solid #f4d986; outline-offset:1px; }
.table-inspector-content,.battle-board .equipment-slot__details { position:fixed; z-index:16; inset: max(60px,10vh) auto auto 50%; transform:translateX(-50%); width:min(620px,calc(100vw - 28px)); max-height:70dvh; overflow:auto; overscroll-behavior:contain; padding:16px; margin:0; border:1px solid #bbac72; border-radius:10px; background:#142d25; color:#e9e5cf; box-shadow:0 15px 60px #000c; overflow-wrap:anywhere; }
.table-inspector-content > header { display:flex; justify-content:space-between; align-items:center; position:sticky; top:-16px; background:#142d25; padding:4px 0 8px; z-index:1; }
.table-inspector-content .btn { min-height:44px; }
.table-inspector-content .hero-skills { margin:0; }
.table-inspector-content .table-inspector-content { z-index:17; }
.play-area { display:grid; grid-template-columns:auto minmax(160px,1fr) minmax(140px,1fr); gap:12px; align-items:center; padding:8px 16px; background:radial-gradient(ellipse,#266446,#153a2b); overflow:hidden; }
.play-area-heading { color:#d4ceac; font-size:11px; }
.play-area-heading > span { display:block; margin-top:4px; }
.battle-board .center-well { gap:16px; min-width:0; }
.battle-board .pile { width:44px; height:58px; flex-shrink:0; font-size:12px; }
.battle-board .pile b { font-size:20px; }
.battle-board .table-status { min-width:0; font-size:15px; }
.battle-board .table-status small { font-size:11px; }
.recent-discards { display:flex; justify-content:center; gap:8px; min-width:0; }
.recent-discard { display:flex; align-items:center; gap:3px; }
.recent-discard > span { font-size:10px; color:#e4cd89; }
.recent-discards .sgs-card { width:58px; height:82px; cursor:default; }
.recent-discards .sgs-card:hover { transform:none!important; }
.recent-discards.is-empty { padding:12px; border:1px dashed #acb48366; border-radius:6px; color:#bdcdb9; font-size:12px; text-align:center; }
.recent-discards p { margin:0; }
.recent-discards p span { font-size:11px; }
.play-area-hint { display:none; }
.player-row { display:grid; grid-template-columns:300px minmax(0,1fr); gap:8px; min-height:0; min-width:0; }
.self-panel { padding:8px; display:grid; grid-template-rows:22px minmax(0,1fr) 44px; gap:5px; }
.player-controls { min-height:0; min-width:0; border:1px solid #8f7d48; border-radius:10px; background:#171b13; overflow:hidden; }
.player-controls > .prompt-controls { display:block; height:100%; min-height:0; }
.sgs-table .action-dock { height:100%; min-height:0; padding:8px; display:flex; flex-direction:column; gap:4px; border:0; overflow:auto; scrollbar-color:#b0a169 #182a20; }
.sgs-table .dock-tip { font-size:12px; line-height:1.3; margin:0; flex-shrink:0; }
.sgs-table .dock-main { display:grid; grid-template-columns:140px minmax(0,1fr); flex:1 0 125px; min-height:0; align-items:stretch; gap:8px; }
.sgs-table .skill-rail { min-height:0; max-width:none; overflow:auto; padding:4px; display:flex; flex-direction:column; flex-wrap:nowrap; gap:6px; }
.sgs-table .active-skill-control { display:grid; grid-template-columns:1fr; gap:3px; flex:0 0 auto; }
.sgs-table .skill-status { font-size:11px; line-height:1.3; }
.sgs-table .skill-rail-title { display:none; }
.sgs-table .hand-stage { min-height:0; height:100%; max-width:100%; padding:8px 4px; gap:6px; flex-wrap:nowrap; justify-content:flex-start; align-items:center; overflow:auto; scrollbar-color:#b0a169 #182a20; scrollbar-width:auto; }
.sgs-table .hand-stage .sgs-card { width:86px; height:122px; margin:0; transform:none; }
.sgs-table .hand-stage .sgs-card:hover:not(:disabled) { transform:translateY(-3px); }
.sgs-table .dock-actions { margin:0; flex-shrink:0; flex-wrap:nowrap; overflow-x:auto; justify-content:flex-end; }
.sgs-table .dock-actions .btn,.sgs-table .skill-seal { min-height:44px; flex-shrink:0; }
.sgs-table .action-dock > details { flex-shrink:0; font-size:12px; }
.sgs-table .thinking-dock,.sgs-table .end-dock { height:100%; min-height:0; overflow:auto; padding:12px; }
.sgs-table .modal-mask { z-index:40; }
.sgs-table .sgs-dialog { max-height:calc(100dvh - 24px); }
.sgs-table .log-rail { z-index:35; max-height:calc(100dvh - 60px); overflow:auto; }
@media (max-width:640px) {
  .sgs-table .table-chrome { flex-direction:column; align-items:stretch; padding:4px 8px; gap:3px; }
  .chrome-left { justify-content:space-between; gap:4px; }
  .sgs-table .chrome-left b { font-size:14px; }
  .sgs-table .round,.sgs-table .phase-chip { font-size:11px; }
  .sgs-table .chrome-right { display:flex; justify-content:space-between; gap:4px; flex-wrap:nowrap; }
  .sgs-table .chrome-right .btn { font-size:12px; padding:4px 8px; }
  .sgs-table .seat-order-status { padding:2px 6px; font-size:10px; }
  .seat-order-status > strong { display:none; }
  .battle-board { padding:5px; gap:5px; grid-template-rows:216px minmax(62px,1fr) minmax(340px,46%); }
  .opponent-row { gap:5px; }
  .opponent-panel { padding:5px; grid-template-columns:minmax(0,1fr); grid-template-rows:16px minmax(0,1fr) 44px; gap:3px; }
  .opponent-panel .board-panel-heading { font-size:10px; }
  .board-panel-heading h2 { font-size:11px; }
  .battle-board .general-seat.opponent { grid-template-columns:minmax(0,1fr) 48px; grid-template-rows:60px 88px; gap:3px; }
  .battle-board .general-seat.opponent .portrait { grid-column:1; }
  .battle-board .general-seat.opponent .equip-rail { grid-column:1/-1; grid-row:2; gap:3px; }
  .general-seat.opponent > .table-inspector { grid-row:1; grid-column:2; transform:none; }
  .battle-board .general-seat .opp-hands { grid-row:1; grid-column:2; }
  .battle-board .general-seat .portrait-frame { width:36px; }
  .battle-board .general-seat .portrait-art { height:40px; }
  .battle-board .general-seat .portrait-banner { font-size:10px; }
  .battle-board .general-seat .seat-nick { font-size:10px; }
  .battle-board .general-seat .skill-tag { display:none; }
  .battle-board .equipment-slot__art { display:none; }
  .battle-board .equipment-slot__summary { min-height:44px; padding:2px 4px; }
  .battle-board .equipment-slot__label { display:none; }
  .battle-board .equipment-slot__name { font-size:11px; }
  .play-area { grid-template-columns:1fr 120px; gap:5px; padding:5px; }
  .play-area-heading { display:none; }
  .battle-board .center-well { gap:6px; }
  .battle-board .pile { width:32px; height:42px; font-size:10px; }
  .battle-board .pile b { font-size:15px; }
  .battle-board .table-status { font-size:12px; }
  .battle-board .table-status small { font-size:10px; }
  .recent-discards { gap:3px; }
  .recent-discards .sgs-card { width:34px; height:48px; }
  .recent-discard > span,.recent-discards p span { display:none; }
  .recent-discards.is-empty { padding:4px; font-size:11px; }
  .player-row { grid-template-columns:minmax(0,1fr); grid-template-rows:130px minmax(0,1fr); gap:5px; }
  .self-panel { padding:5px; grid-template-columns:minmax(0,1fr) 70px; grid-template-rows:18px minmax(0,1fr); gap:3px 5px; }
  .self-panel .board-panel-heading { grid-column:1/-1; }
  .battle-board .general-seat.self { grid-template-columns:95px minmax(0,1fr); grid-template-rows:48px 44px; }
  .self-panel > .table-inspector { grid-column:2; grid-row:2; }
  .sgs-table .action-dock { padding:4px; gap:3px; }
  .sgs-table .dock-main { grid-template-columns:90px minmax(0,1fr); flex-basis:100px; gap:4px; }
  .sgs-table .hand-stage .sgs-card { width:68px; height:96px; }
  .sgs-table .skill-status__reason { font-size:10px; }
  .sgs-table .dock-tip { font-size:11px; }
  .sgs-table .dock-actions .btn { font-size:12px; padding:4px 9px; }
}
@media (max-height:500px) and (min-width:641px) {
  .sgs-table .table-chrome { min-height:46px; padding:1px 8px; }
  .sgs-table .chrome-right .btn { padding:3px 8px; font-size:12px; }
  .sgs-table .seat-order-status { font-size:10px; padding:0 8px; }
  .battle-board { padding:3px 6px; gap:4px; grid-template-rows:104px minmax(40px,1fr) 164px; }
  .opponent-panel { padding:3px; grid-template-columns:minmax(0,1fr) 65px; grid-template-rows:minmax(0,1fr); gap:4px; }
  .opponent-panel .board-panel-heading { display:none; }
  .battle-board .general-seat { grid-template-columns:100px minmax(0,1fr); grid-template-rows:48px 44px; gap:2px 4px; }
  .battle-board .general-seat .portrait-frame { width:32px; }
  .battle-board .general-seat .portrait-art { height:34px; }
  .battle-board .general-seat .portrait-banner { font-size:10px; }
  .battle-board .general-seat .skill-tag { display:none; }
  .battle-board .equipment-slot__art { display:none; }
  .battle-board .equipment-slot__label { display:none; }
  .battle-board .equipment-slot__summary { padding:2px 4px; }
  .general-seat.opponent > .table-inspector { transform:translateY(-5px); }
  .battle-board .general-seat .opp-hands { font-size:10px; }
  .player-row { grid-template-columns:270px minmax(0,1fr); gap:5px; }
  .self-panel { padding:3px; grid-template-rows:15px minmax(0,1fr) 44px; gap:2px; }
  .self-panel > .table-inspector > summary { padding:2px; }
  .play-area { padding:2px 8px; gap:8px; }
  .play-area-heading { font-size:10px; }
  .play-area-heading > span { display:none; }
  .battle-board .center-well { gap:8px; }
  .battle-board .pile { width:44px; height:32px; flex-direction:row; gap:4px; font-size:10px; }
  .battle-board .pile b { font-size:14px; }
  .battle-board .table-status { font-size:12px; }
  .battle-board .table-status small { display:none; }
  .recent-discards .sgs-card { width:25px; height:35px; }
  .recent-discards.is-empty { padding:3px; font-size:11px; }
  .recent-discards p span { display:none; }
  .sgs-table .action-dock { padding:3px 5px; gap:2px; }
  .sgs-table .dock-main { grid-template-columns:95px minmax(0,1fr); flex-basis:86px; gap:4px; }
  .sgs-table .hand-stage { padding:3px; }
  .sgs-table .hand-stage .sgs-card { width:58px; height:82px; }
  .sgs-table .dock-tip { font-size:10px; }
  .sgs-table .dock-actions .btn { font-size:12px; padding:3px 9px; }
}
/* Hand counts stay next to health, never on top of the status control. */
.battle-board .general-seat .opp-hands { display:none; }
.seat-hand-count { display:block; font-size:11px; line-height:1.3; color:#d6d1b1; }
.equipment-detail-close { min-height:44px; justify-self:start; }
.battle-board .portrait .mark-row:empty { display:none; }

@media (min-width:641px) { .sgs-table .table-chrome { flex-wrap:nowrap; } .sgs-table .chrome-left,.sgs-table .chrome-right { width:auto; flex-wrap:nowrap; } }
.battle-board .equipment-slot { min-height:44px; }
.battle-board .equipment-slot__summary { grid-template-columns:24px minmax(0,1fr); }
@media (max-width:640px), (max-height:500px) { .battle-board .equipment-slot__summary { grid-template-columns:minmax(0,1fr); } }
/* Fixed rule panels share the page stacking context; target prompts stay above. */
.battle-board .general-seat,.sgs-table .action-dock { z-index:auto; }
.battle-board .general-seat.dead { filter:none; }
.battle-board .general-seat.dead .portrait { filter:grayscale(.75); }
/* Auxiliary equipment/gift actions and long card rules open without pushing the hand. */
.sgs-table .dock-actions > .table-inspector { margin-right:auto; flex-shrink:0; }
.sgs-table .dock-actions > .table-inspector > summary { white-space:nowrap; }
.sgs-table .action-dock .eq-pick { position:fixed; z-index:18; inset:15vh auto auto 50%; transform:translateX(-50%); width:min(600px,calc(100vw - 28px)); max-height:70dvh; overflow:auto; padding:16px; background:#19352a; border:1px solid #bbac72; border-radius:10px; box-shadow:0 15px 60px #000c; }
.sgs-table .action-dock .eq-pick .btn { min-height:44px; }
/* Reset the old centered-seat shrink-to-fit rules inside the new grid. */
.battle-board .opponent-row { align-items:stretch; flex-wrap:nowrap; }
.battle-board .opponent-panel { height:100%; }
.battle-board .general-seat { justify-items:stretch; align-self:start; }
.battle-board .general-seat .equip-rail { width:100%; }
@media (max-width:640px) {
  .battle-board { grid-template-rows:240px minmax(62px,1fr) minmax(340px,46%); }
  .battle-board .general-seat.opponent { grid-template-rows:60px 96px; }
}
@media (max-height:500px) and (min-width:641px) {
  .sgs-table .hand-stage { padding:2px; scrollbar-width:thin; }
  .sgs-table .hand-stage .sgs-card { width:52px; height:74px; }
}
/* Legacy slot container queries must not re-anchor viewport-fixed details. */
.battle-board .equipment-slot { container-type:normal; }
.battle-board .general-seat .equipment-slot__details { position:fixed; inset:max(60px,10vh) auto auto 50%; width:min(620px,calc(100vw - 28px)); max-height:70dvh; padding:16px; border:1px solid #bbac72; border-radius:10px; }
.battle-board .equipment-detail-close { position:sticky; top:-16px; z-index:1; justify-self:end; background:#19352a; color:#eee0ba; }
@media (max-width:640px), (max-height:500px) {
  .battle-board .equipment-slot__label { display:block; font-size:11px; line-height:1.1; }
  .battle-board .equipment-slot__copy { gap:1px; }
  .battle-board .equipment-slot__name { font-size:11px; line-height:1.1; }
  .battle-board .equipment-slot__stat { font-size:10px; line-height:1.1; }
  .battle-board .equipment-slot.is-empty .equipment-slot__stat { display:none; }
}
.battle-board .general-seat > .table-inspector { transform:none; }
/* Short portrait phones retain the same three bands with a smaller hand, not page clipping. */
@media (max-width:640px) and (max-height:740px) {
  .sgs-table .table-chrome { padding:2px 4px; gap:0; }
  .sgs-table .chrome-left { line-height:18px; }
  .sgs-table .phase-chip { padding:1px 3px; font-size:10px; line-height:16px; }
  .battle-board { grid-template-rows:228px minmax(36px,1fr) 286px; }
  .battle-board .general-seat.opponent { grid-template-rows:48px 96px; }
  .battle-board .general-seat.opponent .portrait-art { height:32px; }
  .player-row { grid-template-rows:122px minmax(0,1fr); }
  .self-panel { padding:3px; grid-template-rows:14px minmax(0,1fr); }
  .sgs-table .dock-main { flex-basis:86px; }
  .sgs-table .hand-stage { padding:2px; scrollbar-width:thin; }
  .sgs-table .hand-stage .sgs-card { width:52px; height:74px; }
  .battle-board .table-status small { display:none; }
  .battle-board .pile { height:30px; }
  .recent-discards .sgs-card { height:32px; width:24px; }
}
/* Keep controls inside device notches/home indicators; env() is zero on desktops. */
.sgs-table { padding-left:env(safe-area-inset-left,0px); padding-right:env(safe-area-inset-right,0px); padding-bottom:env(safe-area-inset-bottom,0px); box-sizing:border-box; }
@media (max-height:500px) and (min-width:641px) {
  .battle-board { grid-template-rows:104px minmax(24px,1fr) calc(164px - min(14px,env(safe-area-inset-bottom,0px))); }
  .self-panel { grid-template-rows:calc(15px - min(15px,env(safe-area-inset-bottom,0px))) minmax(0,1fr) 44px; }
  .self-panel .board-panel-heading { overflow:hidden; }
  .sgs-table .dock-main { flex-basis:calc(86px - min(12px,env(safe-area-inset-bottom,0px))); }
  .sgs-table .hand-stage .sgs-card { height:calc(74px - min(12px,env(safe-area-inset-bottom,0px))); }
}
/* Passive-only heroes give the hand the full dock width; active controls keep their rail. */
.sgs-table .dock-main.dock-main--hand-only { grid-template-columns:minmax(0,1fr); }

/* Parchment dialogs must not inherit the dark tabletop's pale text palette. */
.sgs-dialog { color:#30271c; }
.sgs-dialog .response-context { color:#30271c; background:#eadbb8; }
.sgs-dialog .response-context strong { color:#543715; }
.sgs-dialog .response-context small,
.sgs-dialog .response-kicker,
.sgs-dialog .material-progress,
.sgs-dialog .converted-card-source,
.sgs-dialog .yxs-modern-choices small,
.sgs-dialog .sgs-identity-next-public-card,
.sgs-dialog .sgs-identity-next-h8 { color:#485044; }
.sgs-dialog .counter-verdict { color:#203e32; background:#cedbc2; border-color:#426b50; }
.sgs-dialog .counter-verdict.is-cancelled { color:#63351e; background:#eed0aa; border-color:#8a542d; }
.sgs-dialog .fifth-skill-context.is-irreversible { color:#542c22; background:#efd4bf; }
.sgs-dialog .fifth-skill-context.is-irreversible strong { color:#692e21; }
.sgs-dialog .sgs-followup-hidden-card { color:#f3e4bc; }
