/* One shell keeps the header and navigation in the same place on every page. */
body[data-view]{height:100dvh;overflow:hidden}
body[data-view] #app-shell{display:flex;flex-direction:column;height:100dvh;overflow:hidden}
body[data-view] .app-header{height:66px;flex:0 0 66px;width:100%;margin:0;padding-inline:max(24px,calc((100vw - 1160px)/2))}
body[data-view] .app-header .brand{font-size:24px}
body[data-view] .app-header .gwent-stamp{width:37px;height:37px;margin-left:7px}
body[data-view] #main{display:flex;flex-direction:column;flex:1 1 0;min-height:0;width:100%;padding:16px 28px 0;overflow:hidden}
body[data-view] .view.active{display:flex;flex-direction:column;flex:1 1 0;min-height:0;overflow:hidden}
body[data-view] .bottom-nav{position:relative;left:auto;bottom:auto;transform:none;flex:0 0 72px;align-self:center;width:420px;height:72px;min-height:72px;max-width:calc(100% - 28px);margin:12px auto max(12px,env(safe-area-inset-bottom));padding:7px}
body[data-view] .bottom-nav a{min-height:56px;font-size:14px;gap:6px}
body[data-view] .bottom-nav .nav-icon{width:24px;height:24px}
body[data-view] .play-heading{flex:0 0 auto;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);gap:12px;min-height:44px;margin-bottom:14px}
body[data-view] .play-heading #round-status{font-size:17px;padding:10px 18px}
.play-content{display:flex;flex-direction:column;flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:0 6px 4px 0;scrollbar-gutter:stable}
.play-content>.scoreboard,.play-content>.round-controls,.play-content>#round-log,.play-content>#match-save{flex:0 0 auto}
.play-content .round-controls{margin-top:16px}

/* Borders describe the layout; ability colours still describe the cards. */
.library-card,.saved-deck{border:1px solid var(--line)}
.score-player::before,.score-player::after,.player-total::after{display:none;content:none}
.selected-row.leader-row{background:#f5f7fa;border-bottom-color:var(--line)}
.selected-row.leader-row .selected-name small,.selected-role{color:#637184}
button:focus,a:focus,input:focus,select:focus,textarea:focus,summary:focus,[tabindex]:focus{outline:none;box-shadow:none}
input:focus,select:focus,textarea:focus{border-color:#b3bdcb}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible,[tabindex]:focus-visible{outline:2px solid #697586;outline-offset:2px}
input:focus-visible,select:focus-visible,textarea:focus-visible{outline:none;border-color:#93a0b1;box-shadow:inset 0 0 0 1px #93a0b1}
#card-grid:focus-visible,#builder-results:focus-visible,.selected-list:focus-visible,.history-list:focus-visible,.play-content:focus-visible{outline-offset:-3px}

/* The two gems use facets, with a muted outline of the same form once lost. */
.gems{display:flex;align-items:center;gap:9px}
.gems .gem{position:relative;display:block;width:25px;height:31px;flex:0 0 auto;clip-path:polygon(25% 0,75% 0,100% 30%,50% 100%,0 30%);background:conic-gradient(from 25deg at 50% 31%,#aa7836 0deg 50deg,#e1bf72 50deg 110deg,#8a5d24 110deg 155deg,#d4a854 155deg 225deg,#f7e3ad 225deg 295deg,#c89945 295deg 360deg)}
.gems .gem::before{content:"";position:absolute;inset:0;background:#fff5ce;clip-path:polygon(25% 0,75% 0,50% 31%);opacity:.8}
.gems .gem::after{content:"";position:absolute;inset:0;background:#f6dc94;clip-path:polygon(25% 0,50% 31%,0 30%);opacity:.8}
.gems .gem.gem-lost{background:conic-gradient(from 25deg at 50% 31%,#bdc6d1 0deg 50deg,#dce2e9 50deg 110deg,#afb9c7 110deg 155deg,#c9d1dc 155deg 225deg,#edf0f4 225deg 295deg,#c8d1dd 295deg 360deg);opacity:.65}
.gems .gem.gem-lost::before,.gems .gem.gem-lost::after{background:#f1f4f7}

.row-extras{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-top:9px}
.row-extras>label,.row-extras label{display:flex;align-items:center;gap:12px;margin:0;font-size:12px}
.fixed-stepper{display:flex;align-items:stretch;flex:0 0 auto;height:46px;border:1px solid var(--line);border-radius:9px;background:#fff;overflow:hidden}
.fixed-stepper>input{width:54px;height:44px;min-height:44px;padding:4px;text-align:center;border:0;border-radius:0;font-size:16px;font-weight:650}
.fixed-arrows{display:flex;flex-direction:column;width:31px;flex:0 0 31px;border-left:1px solid var(--line)}
.fixed-arrows>button{display:grid;place-items:center;flex:1 1 0;width:30px;min-height:0;height:22px;padding:0;background:#f0f3f7;color:#647386}
.fixed-arrows>button+button{border-top:1px solid #dde4ed}
.fixed-arrows>button:hover{background:#e1e7ef}
.fixed-arrows svg{display:block;width:13px;height:13px;pointer-events:none}
.fixed-stepper>input:focus-visible,.fixed-arrows>button:focus-visible{outline-offset:-2px}

/* Explicit tracks reserve room for scrollbars, separate from card content. */
#card-grid.card-rail{padding:10px 10px 8px;border:1px solid var(--line);border-radius:14px;background:#edf1f5;overflow-x:scroll;overflow-y:hidden;scrollbar-width:auto;scrollbar-color:#8c99ab #edf1f5;scroll-padding-inline:10px}
#card-grid.card-rail::-webkit-scrollbar{height:12px}
#card-grid.card-rail::-webkit-scrollbar-track{background:#edf1f5;border-radius:8px}
#card-grid.card-rail::-webkit-scrollbar-thumb{background:#8c99ab;border:3px solid #edf1f5;border-radius:8px}
#builder-results.builder-grid,.deck-sheet .selected-list,.recent-matches .history-list{scrollbar-gutter:stable;scrollbar-width:auto;scrollbar-color:#8c99ab #edf1f5;overflow-y:scroll;overflow-x:hidden}
#builder-results.builder-grid::-webkit-scrollbar,.deck-sheet .selected-list::-webkit-scrollbar,.recent-matches .history-list::-webkit-scrollbar,.play-content::-webkit-scrollbar{width:12px;height:12px}
#builder-results.builder-grid::-webkit-scrollbar-track,.deck-sheet .selected-list::-webkit-scrollbar-track,.recent-matches .history-list::-webkit-scrollbar-track,.play-content::-webkit-scrollbar-track{background:#edf1f5;border-radius:8px}
#builder-results.builder-grid::-webkit-scrollbar-thumb,.deck-sheet .selected-list::-webkit-scrollbar-thumb,.recent-matches .history-list::-webkit-scrollbar-thumb,.play-content::-webkit-scrollbar-thumb{background:#8c99ab;border:3px solid #edf1f5;border-radius:8px}
#builder-results.builder-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;padding:10px 8px 10px 10px;border:1px solid var(--line);border-radius:14px;background:#edf1f5}
#builder-results .library-card{border-radius:11px;box-shadow:none}
#builder-results .card-open{display:grid;grid-template-columns:minmax(57px,.38fr) minmax(0,1fr);grid-template-rows:minmax(0,1fr);align-items:stretch;min-height:116px;padding:8px;gap:8px}
#builder-results .card-open img,#builder-results .card-open .art-missing{display:block;width:100%;height:100%;min-height:0;min-width:0;object-fit:cover;object-position:center 30%;margin:0;border-radius:6px}
#builder-results .card-open .art-missing{display:grid;place-items:center;background:linear-gradient(145deg,#e2e8ef,#cad4df)}
#builder-results .card-copy{display:flex;flex-direction:column;min-width:0;padding:0}
#builder-results .card-copy strong{font-size:12px;line-height:1.3;padding:0}
#builder-results .card-copy small{display:block;font-size:10px;line-height:1.3;margin:5px 0 3px}
#builder-results .card-meta{font-size:10px;line-height:1.3;margin:0}
#builder-results .ability-chips{margin-top:auto;padding-top:7px;gap:3px}
#builder-results .ability-chip{font-size:9px;line-height:1.25;padding:3px 5px}
#builder-results .power-badge{top:12px;left:12px;right:auto;height:22px;min-width:22px;font-size:12px;background:#fffffff0;box-shadow:0 1px 4px #11182718}
#builder-results .library-foot{min-height:44px;padding:0 6px;gap:5px;flex-wrap:nowrap;background:#fafbfc}
#builder-results .library-foot code,#builder-results .library-foot>span{font-size:10px;line-height:1.3}
#builder-results .add-card{min-height:44px;min-width:44px;border-radius:7px;padding:5px 7px;font-size:11px;background:transparent}
#builder-results .add-card:hover{background:#e7edf4}
.deck-sheet .selected-list{border:0;border-radius:11px;background:#f5f7fa;padding:7px 7px 7px 9px}
.selected-row:last-child{border-bottom:0}
.selected-list>.empty,.selected-list>.selected-empty,.selected-list>.selection-empty{display:block;min-height:0;padding:9px 3px;margin:0;border:0;border-radius:0;background:none;box-shadow:none;text-align:left;font-size:12px;font-weight:400;line-height:1.6;color:var(--muted)}
.deck-sheet .selected-list.is-empty{background:none;border-radius:0;padding-top:0;overflow-y:auto}

/* The history frame stays put while only the result rows scroll. */
.recent-matches.panel{display:flex;flex-direction:column;flex:1 1 0;min-height:0;overflow:hidden;margin-top:14px;padding:16px;border-radius:16px}
.recent-matches>.section-heading{display:flex;flex:0 0 auto;align-items:center;justify-content:space-between;min-height:30px;margin:0 0 12px}
.recent-matches>.section-heading h2{font-size:19px;margin:0;color:var(--navy)}
.recent-matches .history-list{flex:1 1 0;min-height:0;gap:9px;padding:0 8px 3px 0}
.recent-matches .history-list>.empty{border:0;border-radius:0;background:none;box-shadow:none;padding:26px 16px}
.recent-matches .history-row{border-radius:11px;background:#f8fafc;min-height:76px}

.dialog-close,.filter-close{display:grid;place-items:center;width:44px;height:44px;min-width:44px;min-height:44px;padding:0;border:0;border-radius:50%;background:#edf1f5;color:#647386;line-height:1;text-decoration:none}
.dialog-close svg,.filter-close svg{display:block;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.dialog-close:hover,.filter-close:hover{background:#dfe6ef;color:#344359}
.card-detail{align-items:center;padding-block:24px}
.card-detail .detail-art{display:flex;align-items:center;justify-content:center;align-self:stretch}
.card-detail .detail-art img{display:block;max-width:100%;height:auto;margin:0}
.filter-panel-heading{display:flex;grid-column:1 / -1;align-items:center;justify-content:space-between;min-height:44px;margin:-3px -2px 0 0;gap:12px;font-size:14px;font-weight:700;color:var(--navy)}
.filter-panel-heading .filter-close{flex:0 0 44px}
.filters-toggle[aria-expanded="true"]{background:#e8edf3;border-color:#cbd3df;color:#344359}
.filter-panel-heading{position:sticky;top:-10px;z-index:2;background:#fff;padding-block:3px}

@media(min-width:681px){
  .play-content .player-top{padding:14px 18px 6px}
  .play-content .player-total{padding:0 18px 10px}
  .play-content .total{font-size:68px;line-height:1.12;letter-spacing:-4px}
  .play-content .combat-row{padding:8px 0}
  .play-content .round-controls{margin-top:12px}
  .play-content .deck-choice{padding:9px 18px 12px}
}

@media(max-width:900px){
  #builder-results.builder-grid{grid-template-columns:1fr}
  #builder-results .card-open{grid-template-columns:minmax(66px,.34fr) minmax(0,1fr);min-height:116px}
}
@media(max-width:680px){
  body[data-view] .app-header{padding-inline:16px}
  body[data-view] .app-header .brand{font-size:22px}
  body[data-view] .app-header .gwent-stamp{width:33px;height:33px;margin-left:4px}
  body[data-view] #main{padding:12px 14px 0}
  body[data-view] .play-heading{gap:8px;margin-bottom:11px}
  body[data-view] .play-heading #round-status{font-size:14px;padding:10px 11px;max-width:150px}
  body[data-view] .play-heading #new-match{font-size:12px;padding:10px;min-height:44px}
  .play-content{padding-right:3px}
  .gems .gem{width:23px;height:29px}
  .row-extras,.row-extras label{gap:11px}
  #builder-results.builder-grid{padding:6px 3px 6px 6px;gap:7px;border-radius:11px}
  #builder-results .card-open{grid-template-columns:minmax(0,1fr);grid-template-rows:68px auto;min-height:0;padding:7px;gap:7px}
  #builder-results .card-copy strong{font-size:11px}
  #builder-results .card-copy small,#builder-results .card-meta{font-size:9px}
  #builder-results .ability-chips{padding-top:5px}
  #builder-results .ability-chip{font-size:8px;padding:3px 4px}
  #builder-results .library-foot{padding:0 4px;gap:3px;flex-wrap:wrap}
  #builder-results .library-foot code,#builder-results .library-foot>span{font-size:9px}
  #builder-results .add-card{font-size:10px;padding:4px;min-width:36px}
  #builder-results .power-badge{top:11px;left:11px}
  .deck-sheet .selected-list{padding:6px 3px 6px 6px;border-radius:9px}
  .selected-list>.empty,.selected-list>.selected-empty,.selected-list>.selection-empty{font-size:11px;padding:7px 1px}
  .recent-matches.panel{padding:12px;margin-top:12px;border-radius:14px}
  .recent-matches>.section-heading{margin-bottom:9px}
  .recent-matches>.section-heading h2{font-size:17px}
  .recent-matches .history-list{padding-right:5px}
  .recent-matches .history-row{padding:11px;gap:8px}
}

/* Card details reserve their artwork and dialog size before images load. */
#detail-dialog{ text-transform:none }
#detail-dialog :is(button,.button,.pill,.ability-chip,h3,.eyebrow){text-transform:capitalize}
#detail-dialog.card-dialog{width:min(720px,calc(100vw - 32px));max-width:none;height:min(384px,calc(100dvh - 32px));max-height:none;padding:24px 28px;overflow:hidden}
.card-dialog #dialog-body{height:100%;min-height:0}
.card-dialog .card-detail{height:100%;min-height:0;grid-template-columns:234px minmax(0,1fr);gap:24px;align-items:center;padding:0}
.card-dialog .detail-art{align-self:center;justify-self:center;display:flex;align-items:center;justify-content:center;width:auto;height:100%;max-width:100%;min-height:0;aspect-ratio:252 / 362;border-radius:12px;overflow:hidden}
.card-dialog .detail-art img,.card-dialog .detail-art .art-missing{display:block;width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain;aspect-ratio:252 / 362;border-radius:inherit;margin:0}
.card-dialog .detail-art .art-missing{display:grid;place-items:center}
.card-dialog .detail-copy{max-height:100%;min-width:0;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:8px;scrollbar-gutter:stable}
.card-dialog .detail-copy h2{overflow-wrap:anywhere}
@media(max-width:680px){
 /* Match popup height to the artwork column, leaving 24px above and below it. */
 #detail-dialog.card-dialog{height:min(384px,calc(61.565vw - 2.48px),calc(100dvh - 32px));padding:24px 18px}
 .card-dialog .card-detail{grid-template-columns:minmax(100px,.75fr) minmax(0,1fr);gap:14px}
 .card-dialog .detail-art{width:auto}
 .card-dialog .detail-copy{padding-right:3px}
 .card-dialog .detail-copy h2{font-size:20px}
 .card-dialog .detail-copy .flex{gap:5px}
 .card-dialog .detail-copy .pill{font-size:11px;padding:5px 7px}
}
