/* readable-type-v11: viewport typography, separate mobile card progression and scrolling. */
:root {
  --text-scale: 1;
  --type-body: calc(1rem * var(--text-scale));
  --type-label: calc(.875rem * var(--text-scale));
  --type-detail: calc(.8125rem * var(--text-scale));
  --type-title: calc(1.375rem * var(--text-scale));
  --type-emphasis: calc(1.125rem * var(--text-scale));
  --type-hand: var(--type-body);
}
:root[data-text-size="large"] { --text-scale: 1.08; }
:root[data-text-size="largest"] { --text-scale: 1.16; }
@media (min-width: 1200px) and (min-height: 700px) {
  :root {
    --type-body: calc(1.125rem * var(--text-scale));
    --type-title: calc(1.625rem * var(--text-scale));
    --type-detail: calc(.875rem * var(--text-scale));
  }
}
@media (max-height: 520px) {
  :root { --type-hand: calc(.9375rem * var(--text-scale)); }
}

/* Sheet content wraps and scrolls. Sheet actions stay reachable. */
#overlay .board:not(:has(.logo)) { max-width: min(1040px, 96vw); }
#overlay .board:has(.dk) { max-width: min(1220px, 96vw); }
#ovp, #ask .panel, #cer .reveal, #cdemo .cdBox,
#discovery, #teamEditor {
  font-size: var(--type-body);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
html.mob #overlay .board { max-width: none; }
#ovp :is(h2, .dkHead h2), #ask h2 { font-size: var(--type-title) !important; line-height: 1.18; }
#ovp :is(h3, .shelfHd b, .cxSec > b, .ydSec) { font-size: var(--type-emphasis); }
#ovp :is(.btn, .tab, .dkFilt button), #ask .btn, #cer .btn, #cdemo .btn {
  font-size: var(--type-body) !important;
  line-height: 1.2;
  white-space: normal;
}
#ovp :is(.tab, .dkFilt button) { font-size: var(--type-label) !important; }
#ovp :is(.dim, small, .dkHelp, .dkSides, .credit, .pick .meta, .pick .tkw,
  .achRow .at span, .arcRow .nm small, .ydTx span, .goatSay, .dkFoe, .chBanProg span,
  .paper .mast, .paper .plab, .lsT small) {
  font-size: var(--type-detail) !important;
  line-height: 1.3;
}
#ovp :is(.dkGrid.dkFixed .pick b, .pick b, .pick .nm, .lv b, .lsT b, .cer-card b), #cer .cer-card b {
  font-size: var(--type-label) !important;
  line-height: 1.18;
  min-height: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
#ovp :is(.shopSay, .note .nbody, .paper .pcols p, .tip.brief, .dkInfo .d),
#cdemo :is(.cdDesc, .cdD), #cer .cer-desc, #ask p {
  font-size: var(--type-body) !important;
  line-height: 1.45;
}
#ovp :is(.tip.brief summary, .dkInfo .cdBtn, .avg, .lv .rw, .lv .tag) { font-size: var(--type-detail); }
#ovp :is(.dkHelp, .dkSides, .shopSay span, .arcRow .nm, .lsT small) {
  white-space: normal;
  max-width: none;
  text-overflow: clip;
}
#ovp .shopGrid .pick small { display: block; overflow: visible; }
#ovp .chBan .mapCh { font-size: var(--type-label) !important; }
html.mob #ovp .chBan .mapDesc { display: none !important; }
#ovp :is(.dkGrid, .dkGrid.dkFixed, .dkGrid.cxLock) {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(6.2rem * var(--text-scale))), 1fr)) !important;
}
#ovp .shopGrid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(9rem * var(--text-scale))), 1fr));
}
#ovp .dkGrid .pick .cst, #ovp .dkSlots .slot .cst {
  font-size: var(--type-label);
  min-width: calc(1.4rem * var(--text-scale));
  min-height: calc(1.4rem * var(--text-scale));
}
#ovp .dkGrid .pick .vw {
  font-size: var(--type-detail) !important;
  min-width: 30px;
  min-height: 30px;
}
#ovp .dkGrid .pick .vw::after { content: ""; position: absolute; inset: -7px; }
#ovp .setRow, #ovp .mapHead, #ovp .dkTitle { flex-wrap: wrap; }
#ovp :is(.setRow b, .dkTitle, .mapHead h2) { white-space: normal; }
#ovp .setRow > div { min-width: 0; }
#ovp .textSizeChoices { display: flex; flex-wrap: wrap; gap: 6px; }
#ovp .dkBrief { max-height: none !important; overflow: visible; }
#ovp .acts .dkInfo {
  min-height: 0 !important;
  max-height: 32dvh !important;
  align-content: flex-start;
}
#cdemo .cdBox { width: min(880px, 95vw); max-height: 96dvh; }
#cdemo .cdHead { flex-wrap: wrap; font-size: var(--type-body); }
#cdemo .cdHead b { min-width: 0; overflow-wrap: anywhere; }
#cdemo .cdBox canvas { max-height: 57dvh; width: 100%; object-fit: contain; }
#discovery .discovery-card > strong { font-size: var(--type-body); }
#discovery .discovery-detail { font-size: var(--type-label); color: #35463b; }
#discovery .discovery-cost { font-size: var(--type-label); }

/* Hand labels are capped independently of the artwork and status badges. */
#hand {
  --hand-card-width: clamp(80px, 13.5vh, 106px);
  min-width: calc(4 * var(--hand-card-width) + 3 * clamp(6px, 1vw, 10px));
}
#hand .card { container-type: inline-size; flex: 0 0 auto; width: var(--hand-card-width); }
#hand .card .nm {
  left: 2px !important;
  right: 2px !important;
  bottom: 2px !important;
  display: grid;
  grid-template-rows: 1.3em 1.16em;
  gap: 1px;
  padding: 3px 2px !important;
  font-size: min(var(--type-hand), 18cqw, 2.55vh) !important;
  letter-spacing: 0 !important;
  background: linear-gradient(#22324f, #101929 45%) !important;
}
#hand .hand-name, #hand .card .nm > small, #hand .card .kwx {
  display: block;
  min-width: 0;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
#hand .card .nm .kw {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  margin: 0;
  font-size: min(var(--type-detail), 13cqw, 2.45vh) !important;
}
#hand .card .nm .kwi { flex: none; }
#hand .card .nm > small { font-size: min(var(--type-detail), 13cqw, 2.45vh); color: #fff1b8; }
#hand .card .cost, #energy .lbl b { font-size: var(--type-emphasis) !important; }
#hand .card .cost { min-width: calc(1.55rem * var(--text-scale)); min-height: calc(1.55rem * var(--text-scale)); }
#energy .lbl, #hand .card.sel .kwt, #next span, #readyBtn small {
  font-size: var(--type-label) !important;
}
#readyBtn { font-size: var(--type-emphasis); min-height: 44px; line-height: 1.1; }
#cardinfo { font-size: var(--type-label); white-space: normal; line-height: 1.4; border-radius: 12px; text-align: center; }
#hint, #guideTip, #coach .cb, #dragCancel { font-size: var(--type-body) !important; line-height: 1.35; }
#teamCard .tcT b { font-size: var(--type-label); }
#teamCard .tcS em { font-size: var(--type-detail); }
#achToast { font-size: var(--type-label) !important; }
#calls button, #calls .tell, #calls .lb, #calls button small { font-size: var(--type-label); }
#gm input, #gm select, #gm button, #gm pre { font-size: var(--type-detail); }
@media (pointer: coarse) {
  #ovp .btn, #ask .btn, #cer .btn, #cdemo .btn { min-height: 44px; }
}
@media (max-height: 520px) {
  #hand { --short-card: clamp(78px, 11.7vw, 96px); min-width: 0; }
  :root[data-text-size="large"] #hand { --short-card: clamp(82px, 12.1vw, 100px); }
  :root[data-text-size="largest"] #hand { --short-card: clamp(86px, 12.8vw, 104px); }
  #hand .card { width: var(--short-card) !important; }
  #hand .card > img.face { object-position: 50% 0%; }
  #hand .card .nm { grid-template-rows: 1.15em; padding: 2px 2px !important; font-size: min(var(--type-hand), 18cqw) !important; }
  #hand .card .hand-name { line-height: 1.15; }
  #hand .card.spell::after, #hand .card .nm .kw, #hand .card .nm > small { display: none !important; }
  #readyBtn { min-width: clamp(96px, 14vw, 122px); padding: 6px 10px 8px !important; }
  #readyBtn:not(.bonus) small { display: none; }
  #readyBtn.bonus small { font-size: var(--type-detail) !important; padding: 1px 7px; }
  #ovp .grid.route { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  :root[data-text-size="large"] #ovp .grid.route,
  :root[data-text-size="largest"] #ovp .grid.route { grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(8.5rem * var(--text-scale))), 1fr)) !important; }
  #ovp .mapTop .tabs { flex-wrap: wrap; overflow: visible; }
  #ovp .acts:has(.dkInfo) { flex-wrap: wrap !important; }
  html.mob #ovp .acts .dkInfo { flex-basis: 100% !important; }
  #coach { max-width: min(44%, 365px); }
}
@media (max-width: 600px) and (min-height: 521px) {
  #ovp .dk { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  #ovp .grid.route { grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(7rem * var(--text-scale))), 1fr)) !important; }
  #ovp .paper .pcols { display: block; }
}


#rotate { text-align: center; padding: 20px; font-size: var(--type-title); }
#rotate > span { font-size: var(--type-body) !important; }
#ovp :is(input[type="text"], input[type="number"], textarea, select) {
  font-size: var(--type-body);
  max-width: 100%;
}
#ovp .dkRule .big { font-size: var(--type-emphasis); }
#ovp .dkRule ul, #ovp .tip, #ovp .goatSay { font-size: var(--type-body) !important; }
#ovp .arcRow, #ovp .ydItem { flex-wrap: wrap; }
#ovp :is(.arcRow .nm, .ydTx, .achRow .at) { min-width: min(9rem, 100%); }
#ovp .chBan .chBanProg span { font-size: var(--type-detail) !important; }
#ovp .lsT > span b { font-size: calc(1.5rem * var(--text-scale)) !important; }
#ovp .lsT > span em { font-size: var(--type-detail); }
#ovp .credit { color: #596275; }
#ovp .abilL i, #cdemo .abilL i, #cer .abilL i { font-size: var(--type-detail); }
#cdemo .cdX { width: 44px; height: 44px; }
#ovp .setRow > b, #ovp .setRow > label { font-size: var(--type-body) !important; }
#ovp .setRow > b small { font-weight: 600; }
@media (min-height: 521px) {
  html:not(.mob)[data-text-size="large"] #hand,
  html:not(.mob)[data-text-size="largest"] #hand {
    --hand-card-width: clamp(84px, 13vw, 120px);
  }
}
#gm { overflow-wrap: anywhere; }
#gm :is(select, input, button) { max-width: 100%; }
#gm pre { white-space: pre-wrap; }
#gm #gmInfo { white-space: pre-wrap; overflow-wrap: anywhere; }
#ovp :is(.avg i, .cxSec > b i, .dkInfo .nick) { font-size: var(--type-detail); }
#ovp :is(.dkInfo .dkIB > b, .dkInfo .cost, .shopSay b) { font-size: var(--type-label); }
#ovp .dkGrid .pick .ltd {
  position: static;
  order: 3;
  font-size: var(--type-detail);
}

/* §462 手机横屏设置页：行太高一屏只放得下两行半 → 标签 / 分段按钮用 label 字号、按钮 36px（仍跟随「文字大小」） */
@media (max-height: 520px) {
  #ovp .setRow { margin: 0 !important; padding: 3px 4px !important; }
  #ovp .setRow > b, #ovp .setRow > label { font-size: var(--type-label) !important; }
  #ovp .setSeg .btn, #ovp .setActBtn { font-size: var(--type-label) !important; min-height: 36px; padding: 3px 10px !important; }
  #ovp .setTeamMeta { font-size: var(--type-detail); }
}

/* §464 手机横屏结算：顶部比赛数据改成一行小胶囊（原来三块大卡片占半屏） */
@media (max-height: 520px) {
  #ovp .lossStats { gap: 6px; margin: 2px 0 6px; }
  #ovp .lsT { flex-direction: row; min-width: 0; padding: 3px 9px; gap: 5px; border-width: 2px; box-shadow: 0 2px 0 var(--ink, #1b1b2f); }
  #ovp .lsT > i { font-size: 16px; }
  #ovp .lsT > span b, #ovp .lsT > span b { font-size: var(--type-emphasis) !important; }
  #ovp .lsT small { font-size: var(--type-detail); }
  #ovp .lsT.foe img { width: 30px !important; height: 28px !important; margin: 0; }
  #ovp .lsT .lsN { top: -9px; right: -9px; font-size: 11px; }
}

/* Mobile progression is outside the portrait; generic card image rules must not resize star icons. */
html.mob #ovp .dkGrid .pick .lvs{position:static;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:26px;margin:3px 0;max-width:100%;font-size:11px;letter-spacing:0;line-height:12px;color:#8a5c00;text-shadow:none}
html.mob #ovp .dkGrid .pick .levelStars{display:flex;flex-wrap:nowrap;gap:1px;white-space:nowrap}
html.mob #ovp .dkGrid .pick .lvs .talp{margin:0;display:flex}
html.mob #ovp .dkGrid .pick .lvs img.emo{width:10px!important;height:10px!important;flex:none;position:static!important}
html.mob #hand .card .lvs,html.mob #hand .card .lvs.many{top:-21px;right:2px;display:flex;flex-wrap:nowrap;align-items:center;gap:1px;white-space:nowrap;font-size:9px;line-height:10px;letter-spacing:0;padding:2px 3px;border:1px solid #d4a000;border-radius:6px;background:#172132;pointer-events:none}
html.mob #hand .card .lvs:empty{display:none}
html.mob #hand .card .lvs img.emo{width:9px!important;height:9px!important;flex:none;position:static!important;vertical-align:0}
.deckReplace{max-height:calc(100dvh - 28px);overflow:auto;padding:16px}
.deckReplace h3{margin:0 0 8px}.deckReplace p{margin:0 0 12px}
.deckSwapGrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:8px}
.deckSwapGrid button{display:flex;align-items:center;gap:8px;min-height:60px;padding:8px;background:#fff8e6;color:#172132;border:2px solid #172132;border-radius:12px;font:800 14px/1.3 system-ui;text-align:left;cursor:pointer}
.deckSwapGrid button:focus-visible{outline:3px solid #2f80ed;outline-offset:2px}.deckSwapGrid button b{overflow-wrap:anywhere}
/* Reserve the sticky action bar in the deck scroller's visible area. */
#ovp:has(.dkPick){scroll-padding-top:12px;scroll-padding-bottom:calc(4.5rem * var(--text-scale) + 24px)}
#ovp:has(.dkPick)>.acts{margin:12px 0 0!important;bottom:0!important;background:#f7f5e8}
#ovp .dkPick .pick{scroll-margin-block:8px}

/* The landscape deck owns two scrollers; the footer occupies a real grid row. */
@media (orientation:landscape) and (max-height:620px){
 html.mob #ovp:has(.dk:not(.dkDeal)>.dkPick){display:grid;grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden}
 html.mob #ovp .dk:not(.dkDeal){min-height:0;height:100%;overflow:hidden;align-items:stretch;margin-top:0}
 html.mob #ovp .dk:not(.dkDeal)>.dkBrief{position:static;align-self:stretch;height:100%;min-height:0;max-height:none!important;overflow-y:auto;overflow-anchor:none;overscroll-behavior:contain;touch-action:pan-y;padding:4px 8px 14px 0;scroll-padding-block:6px 14px}
 html.mob #ovp .dk:not(.dkDeal)>.dkPick{min-height:0;overflow-y:auto;overflow-anchor:none;overscroll-behavior:contain;touch-action:pan-y;padding:10px 8px 14px 7px;scroll-padding-block:12px 14px}
 html.mob #ovp:has(.dk:not(.dkDeal)>.dkPick)>.acts{position:static;margin:0 -14px!important}
}

/* Result copy scrolls above a real footer row, even without a wager receipt. */
html.mob #ovp:has(>.resultContent){display:grid;grid-template-rows:minmax(0,1fr) auto;overflow:hidden}
html.mob #ovp>.resultContent{min-height:0;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;padding:0 2px 12px;scroll-padding-block:8px 12px}
html.mob #ovp:has(>.resultContent)>.acts{position:static;margin:0 -14px!important}
html.mob #ovp:has(>.resultContent)>.acts .btn{min-height:44px}

/* Codex ranks have one fixed slot; do not inherit the deck's vertical talent stack. */
#ovp .dkGrid.cxCards{grid-template-columns:repeat(auto-fill,minmax(min(100%,calc(6.5rem * var(--text-scale))),1fr))!important}
#ovp .dkGrid .pick.codexCard{padding-top:5px}
#ovp .dkGrid .codexCard>img{align-self:flex-start;margin-left:10px}
#ovp .dkGrid .codexCard .cxLevel{position:absolute;top:3px;right:5px;display:inline-flex;align-items:center;justify-content:center;gap:3px;box-sizing:border-box;width:34px;height:20px;white-space:nowrap;flex:none;border:1px solid #b88b25;border-radius:6px;background:#fff1b8;color:#62420c;font:900 12px/1 var(--font);letter-spacing:0;pointer-events:none}
#ovp .dkGrid .codexCard .cxLevel i{display:block;flex:none;width:12px;height:12px;background:#a56700;clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)}
@media (max-height:520px){
 #ovp .cxHead h2{flex:none;white-space:nowrap}
 #ovp .cxHead .dim{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 #ovp .acts.cxActions{flex-wrap:nowrap!important;align-items:center}
 html.mob #ovp .acts.cxActions .dkInfo{flex:1 1 0!important;min-width:0}
 #ovp .acts.cxActions>.btn{flex:none}
}
@media (max-height:360px){
 html.mob #ovp .acts.cxActions .dkInfo{max-height:68px!important}
 #ovp .acts.cxActions .dkInfo .cdMini{width:96px}
}
