/* Shared finishing pass. Keep duel geometry and game rules in their own modules. */
:root{
 --ui-focus:#f1d58b;
 --ui-secondary:#bdb2cb;
 --ui-page-gutter:clamp(14px,2.5vw,28px);
 --ui-section-gap:20px;
}
:is(.site-workspace,.run-layout,.coop-page,dialog) :is(button,a,input,select,summary):focus-visible{outline:2px solid var(--ui-focus);outline-offset:3px}
:is(.store-content,.site-workspace>main,.db-scroll,dialog){scrollbar-color:#655571 transparent;scrollbar-width:thin}
:is(.store-content,.site-workspace>main){scrollbar-gutter:stable}
:is(.site-workspace,.run-layout,.coop-page,dialog) :is(button,a){-webkit-tap-highlight-color:transparent}
:is(.store-content,.home-hub,.rematch-main,.coop-page) :is(h1,h2,h3){text-wrap:balance}
:is(.store-content,.home-hub,.rematch-main,.coop-page) p{overflow-wrap:break-word}
#store .store-page{padding:24px var(--ui-page-gutter) 20px}
.farm-workspace .farm-main,.coop-workspace .coop-page{padding-inline:var(--ui-page-gutter)}
#store .section-title,.dungeon-hub .dungeon-heading,.farm-main .farm-heading,.coop-page .coop-page-heading,#store .deck-library-heading{margin-bottom:var(--ui-section-gap)}
#store .section-title h1,#store .deck-library-heading h1,.coop-page .coop-page-heading h1{margin-block:0}
#store .section-title p{font-size:13px;line-height:1.6;color:var(--ui-secondary)}
.site-nav .site-nav-item{font-size:13px}
.site-nav .site-nav-credit{line-height:1.6}
/* Filters read as a single tool group, with a consistent control baseline. */
.database-toolbar,.collection-toolbar{padding:14px;border:1px solid #ffffff14;border-radius:12px;background:#ffffff03;align-items:end}
.database-toolbar label,.collection-toolbar label{font-size:12px;gap:7px}
.database-toolbar :is(input,select),.collection-toolbar :is(input,select){min-height:44px;font-size:13px}
#store .collection-results{min-height:48px;font-size:12px;gap:10px}
.collection-results .subtle,.collection-pagination button{min-height:40px;padding:8px 10px}
.collection-pagination{gap:12px;align-items:center}
.database-card{gap:14px;padding:14px;border-radius:12px;transition:border-color .16s,background .16s}
.database-card img{flex:0 0 64px;min-height:93px;border-radius:3px;background:#231b2e}
.database-card strong{font-size:14px;line-height:1.45}
.database-card small,.database-card b{font-size:12px;line-height:1.5}
/* Keep purchase and inspection actions aligned even when names wrap. */
#store .card-tile h3{font-size:14px;line-height:1.4;min-height:2.8em}
#store .card-tile .buy{min-height:44px;font-size:13px}
#store .card-tile .effect-bonus{line-height:1.6}
.pack-shop-card{align-items:stretch}
.pack-shop-info{height:100%;gap:10px}
.pack-shop-info .pack-pool-link{text-align:left;justify-content:flex-start;min-height:40px}
.pack-shop-info .buy{min-height:44px;margin-top:auto}
.pack-shop-info p{color:var(--ui-secondary);font-size:13px;line-height:1.6}
.pack-guarantee{font-size:10px}
.pack-filters{gap:6px;padding-bottom:2px}
.packs-screen .pack-chapter-section+.pack-chapter-section{margin-top:28px;padding-top:22px}
.packs-screen .pack-chapter-heading{margin-bottom:14px}
.packs-screen .pack-chapter-heading h2{margin-bottom:0}
/* Forge: compact, aligned tabs and a readable cost summary. */
#store .forge-section .forge-header .forge-tabs button{min-height:44px;font-size:13px}
#store .forge-grid-heading p,#store .forge-grid-search input{font-size:13px}
#store .forge-grid-card>strong{font-size:13px}
#store .forge-grid-owned,#store .forge-grid-status,#store .forge-grid-path{font-size:11px;line-height:1.5}
#store .forge-summary-copy h3{line-height:1.35}
#store .forge-upgrade-workbench .forge-requirements li{font-size:12px;padding:12px 0}
#store .forge-action-footer .buy{min-height:46px;font-size:13px}
#store .forge-action-footer small{font-size:11px;line-height:1.6}
#store .forge-upgrade-workbench{max-height:calc(100dvh - 100px);overflow:auto;scrollbar-width:thin}
/* Lock the page under modal dialogs and avoid repainting card grids through blur. */
html:has(dialog:modal,.modal-backdrop,.sim-modal-backdrop){overflow:hidden}
:is(.modal-backdrop,.sim-modal-backdrop,.modal,.sim-modal),dialog{overscroll-behavior:contain}
:is(.modal-backdrop,.sim-modal-backdrop),:is(dialog:modal,#deck-editor)::backdrop{backdrop-filter:none}
dialog{scrollbar-gutter:stable;box-shadow:0 24px 90px #0009}
dialog .dialog-close{width:40px;height:40px;display:grid;place-items:center;line-height:1;border:1px solid #ffffff20;background:#292131}
dialog .dialog-close:hover{background:#3b2e48;color:#fff}
.source-title,.card-detail-heading{padding-right:42px}
.source-section .source-help,.source-small{font-size:12px!important;line-height:1.6}
.source-rates{grid-template-columns:repeat(auto-fit,minmax(85px,1fr))}
.source-rates>span{gap:6px;padding:10px;font-size:11px}
.source-rates b{font-size:15px}
.source-farm-link{min-height:44px}
/* A smaller co-op introduction puts the forms and next action in view. */
.coop-entry-card{display:grid;grid-template-columns:44px minmax(0,1fr);align-content:start;gap:16px 14px;padding:22px}
.coop-entry-card>.coop-entry-symbol{grid-column:1;grid-row:1}
.coop-entry-card>div:not(.coop-run-preview){grid-column:2}
.coop-entry-card :is(.coop-form,.coop-run-preview,.coop-entry-note),.coop-entry-card>.text-btn{grid-column:1/-1}
.coop-entry-card h2{margin:4px 0 8px;font-size:24px}
.coop-entry-card .coop-form{align-content:start}
.coop-entry-card>.text-btn{justify-self:start}
.coop-rules{gap:20px;padding-top:20px}
/* Bring supporting text up to a readable size without enlarging the arena. */
.hub-shortcut p,.hub-starter-note,.dashboard-footer{font-size:12px;line-height:1.6}
.dashboard-footer{flex-wrap:wrap}
.farm-workspace .rematch-grid{gap:16px}
.rematch-tile{border-radius:12px}
.rematch-actions{gap:8px;align-items:stretch}
.rematch-actions :is(button,a){min-height:44px}
.market-section-title{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px 16px}
.market-section-title>span{margin:0;line-height:1.5}
.market-exit,.treasury-controls{gap:12px;flex-wrap:wrap}
.ability-upgrades>h3{margin-bottom:10px}
.reveal-heading h2{margin-bottom:8px}
.polished-arena .arena-tools .duel-tool{line-height:1.3}
.polished-arena .info-tabs button:focus-visible{outline:2px solid var(--gold);outline-offset:-3px}
.polished-arena .reference-layout .inspector-copy p{font-size:13px;line-height:1.7}
@media(max-width:950px){#store .forge-upgrade-workbench{max-height:none;overflow:visible}}
@media(max-width:650px){
 #store .store-page{padding-block:18px 20px}
 #store .section-title,.dungeon-hub .dungeon-heading,.farm-main .farm-heading,.coop-page .coop-page-heading,#store .deck-library-heading{margin-bottom:16px}
 #store .section-title{gap:10px;align-items:start}
 #store .section-title h1{font-size:25px}
 #store .section-title p{font-size:12px}
 .database-toolbar,.collection-toolbar{padding:12px;gap:12px}
 .database-toolbar :is(input,select),.collection-toolbar :is(input,select){font-size:14px;padding:10px;min-height:44px}
 #store .collection-results{font-size:11px;align-items:center}
 .database-card{padding:12px;gap:12px}
 .database-card img{flex-basis:58px;min-height:85px}
 .database-card strong{font-size:14px}
 .database-card small,.database-card b{font-size:12px}
 .pack-shop-info h2{font-size:23px}
 .pack-shop-info p{font-size:13px}
 .pack-pool-toolbar{flex-wrap:wrap;gap:8px}
 .pack-pool-toolbar>span{padding-bottom:0}
 #store .forge-section .forge-header .forge-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%;gap:4px}
 #store .forge-section .forge-header .forge-tabs button{font-size:12px;min-height:44px;padding:8px 5px;white-space:normal}
 #store .forge-grid-card>strong{font-size:12px}
 #store .forge-grid-toolbar select,#store .forge-grid-toolbar button{min-height:42px;font-size:12px}
 #store .forge-grid-results{font-size:11px}
 .coop-entry-card{padding:18px;gap:14px 12px}
 .coop-entry-card h2{font-size:22px}
 .source-pack-links{grid-template-columns:1fr}
 .source-duelist{flex-wrap:wrap}
 .source-duelist>span{margin-left:46px}
 .db-mobile-tabs button,.db-filter-toggle,.db-pagination button{min-height:40px}
 .db-search input{min-height:44px;font-size:14px}
 .db-kind-tabs button{min-height:36px;font-size:11px}
 .db-bank-caption b{font-size:11px;height:31px}
 .db-bank-caption small{font-size:10px;white-space:normal}
 .db-card-action{width:30px;height:30px;font-size:20px;display:grid;place-items:center}
 .db-result-tools{flex-wrap:wrap}
 .db-result-tools select{min-height:38px;font-size:12px;width:auto;max-width:100%}
 .db-filters :is(input,select){min-height:40px;font-size:13px}
 .db-deck-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
 .db-save-actions{flex-wrap:wrap}
 .site-nav .site-nav-item{min-height:58px}
 .site-nav-item .nav-short{font-size:10px;text-align:center}
 .hub-dashboard .difficulty-picker select{min-height:44px}
 .dashboard-heading>.text-btn{min-height:40px}
}
@media(prefers-reduced-motion:reduce){.database-card{transition:none}}
/* The side navigation reduces actual workbench width on laptop screens. */
@media(min-width:851px) and (max-width:1450px){
 .db-workbench{grid-template-columns:minmax(0,1.3fr) minmax(300px,1fr)}
 .db-preview{display:none}
 .db-deck-grid{grid-template-columns:repeat(7,minmax(0,1fr))}
 .db-bank-caption b{font-size:11px;height:31px}
 .db-bank-caption small{font-size:10px;white-space:normal}
}
@media(min-width:851px) and (max-width:1000px){.db-deck-grid{grid-template-columns:repeat(5,minmax(0,1fr))}.db-bank-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}

/* Keep controls readable and easy to reach across the shared game screens. */
:where(button,a,input,select,textarea,summary):focus-visible{outline:2px solid #e8c777;outline-offset:3px}
:where(button,a,input,select,textarea){-webkit-tap-highlight-color:#e8c77722}
.collection-pagination,.database-pagination{flex-wrap:wrap;gap:10px;align-items:center}
.collection-pagination button,.database-pagination button{min-height:44px}
.pack-shop-info{min-width:0;display:flex;flex-direction:column;align-items:flex-start}
.pack-shop-info>button:last-child{margin-top:auto}
@media(max-width:650px){
 /* 16px prevents mobile browsers zooming the page when a field gains focus. */
 #store :is(input,select,textarea),.coop-page :is(input,select),.dungeon-hub :is(input,select),.modal :is(input,select),.auto-dungeon-settings :is(input,select){font-size:16px}
 .db-library-preview-grid{grid-template-columns:repeat(auto-fill,minmax(72px,1fr));gap:10px}
 .db-library-preview-card{max-width:none}
 .db-library-preview-actions .db-button,.db-library-preview-actions .buy,.db-mobile-tabs button,.db-filter-toggle,.db-pagination button{min-height:44px}
 .pack-tabs{gap:6px}
 .pack-tabs button{min-height:44px}
}
/* V1 navigation and progression clarity. */
.forge-section-guide,.dungeon-unlock-help{font-size:13px;line-height:1.65;color:#c7bbd3;margin:12px 0 18px;max-width:78ch}
.dungeon-launch .dungeon-unlock-help{position:relative;padding:10px 12px;background:#e8c77708;border-left:2px solid #e8c77760;border-radius:0 6px 6px 0}
.progress-overview{min-width:0;color:#dcd1e7}
.progress-totals{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:12px 0 18px}
.progress-totals>div{display:flex;flex-direction:column;gap:6px;background:#ffffff05;border:1px solid #ffffff14;border-radius:10px;padding:14px}
.progress-totals strong{font-size:24px;color:#f0dfac;font-variant-numeric:tabular-nums}
.progress-totals span{font-size:12px;line-height:1.5;color:#c2b4ce}
.progress-explainer,.progress-chapter p,.progress-automation p,.progress-reset p{font-size:13px;line-height:1.7;color:#c2b4ce}
.progress-chapters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:18px 0}
.progress-chapter{padding:16px;border:1px solid #ffffff1b;border-radius:12px;background:#ffffff03;min-width:0;display:flex;flex-direction:column}
.progress-chapter-heading{display:flex;align-items:start;justify-content:space-between;gap:8px}
.progress-chapter-heading small{font-size:10px;letter-spacing:.1em;color:#d1b974}
.progress-chapter-heading h3{font:600 16px/1.4 Arial,sans-serif;margin:5px 0 12px}
.progress-chapter-heading>span{font-size:11px;color:#c2b4ce;white-space:nowrap;padding-top:3px}
.progress-tier-list{list-style:none;padding:0;margin:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
.progress-tier-list li{padding:8px;background:#ffffff04;border-radius:6px;display:grid;grid-template-columns:14px minmax(0,1fr);gap:3px 5px;font-size:12px}
.progress-tier-list strong{font-weight:500}.progress-tier-list small{grid-column:2;font-size:10px;color:#b0a2bd}
.progress-tier-list .complete{color:#b0dfbf}.progress-tier-list .available{color:#f0d88f}.progress-tier-list .locked{color:#a99bb8}
.progress-chapter .btn{margin-top:auto;min-height:44px;font-size:13px}
.progress-automation{border-top:1px solid #ffffff18;padding-top:6px}.progress-automation h3{font-size:16px}
.progress-links{display:flex;flex-wrap:wrap;gap:8px 18px}.progress-links a{display:flex;align-items:center;min-height:44px;font-size:13px;color:#e8c777}
.progress-reset{margin-top:20px;border-top:1px solid #ffffff18;padding-top:8px}.progress-reset summary{font-size:13px;color:#b5a5c2;min-height:44px;align-content:center;cursor:pointer}
@media(max-width:650px){
 .progress-chapters{grid-template-columns:1fr}.progress-totals{gap:6px}.progress-totals>div{padding:10px}.progress-totals strong{font-size:21px}.progress-totals span{font-size:11px}
 #store .forge-section .forge-header .forge-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;overflow:visible}
 #store .forge-section .forge-header .forge-tabs button{min-height:44px;white-space:normal;padding:9px;font-size:12px}
 .forge-tabs button:last-child{grid-column:1/-1}
 .forge-section-guide{font-size:13px;margin-block:12px}
}
/* Co-op uses a fieldset for save protection; it shares the main content grid slot. */
@media(max-width:650px){
 .site-workspace>.coop-surface{grid-column:1;grid-row:2;min-width:0;min-height:0;width:100%}
 #coop-connection{left:10px;right:10px}
}
/* Show deck names on phones instead of five unexplained slot numbers. */
@media(max-width:620px){
 .deck-library-slots{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
 .deck-library-slot{flex-direction:column;align-items:flex-start;justify-content:flex-start;gap:6px;min-height:86px;padding:10px;min-width:0}
 .deck-slot-number{font-size:11px}
 .deck-slot-name{display:block;min-width:0;width:100%}
 .deck-slot-name b{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;white-space:normal;font-size:12px;line-height:1.4;overflow-wrap:anywhere}
 .deck-slot-name small{display:none}
}
.database-empty{grid-column:1/-1;text-align:center;padding:30px 16px}
.database-empty h3{margin-top:0}.database-empty button{min-height:44px}
.db-recovery-note{padding:10px 12px;border:1px solid #e8c77735;border-radius:8px;background:#e8c77708;color:#d9ccad;font-size:12px;line-height:1.6;margin:10px 0 16px;overflow-wrap:anywhere}
#deck-builder>.db-recovery-note{flex-shrink:0;margin:6px 0 10px;font-size:11px}
.db-discard-dialog>div{display:flex;flex-wrap:wrap;gap:10px}.db-discard-dialog>div>button{min-height:44px}
.draft-save-help{font-size:12px;line-height:1.6;color:#c7bbd3;margin:8px 0;flex-basis:100%}
.pack-draft:has(.draft-save-help){display:flex;flex-direction:column;max-height:calc(100dvh - 64px)}
.pack-draft:has(.draft-save-help)>*{flex-shrink:0}
.pack-draft:has(.draft-save-help)>.draft-save-help{flex-basis:auto}
.pack-draft:has(.draft-save-help)>.pr-group{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior-y:contain}
.draft-resume{gap:12px;flex-wrap:wrap}.draft-resume .buy{min-height:44px}
@media(max-width:600px){.db-discard-dialog>div>button{width:100%}.draft-resume>div{min-width:0}.draft-resume .buy{width:100%}}

.dungeon-results-return{display:flex;justify-content:flex-end;margin:-8px 0 18px}.dungeon-results-return .text-btn{min-height:44px;text-align:right;white-space:normal}

.millennium-promotion-result{padding:11px 13px;border:1px solid #e5c37a4d;border-radius:8px;background:#e5c37a0d;color:#f4dfaa;margin:10px 0}
.millennium-promotion-result p{margin:4px 0 0;font-size:13px;line-height:1.5;color:#c7bbd3}
