.mtgdb-search-app{--gap:24px;position:relative}.mtgdb-layout{display:grid;grid-template-columns:minmax(230px,290px) minmax(0,1fr);gap:var(--gap);align-items:start}.mtgdb-panel{position:sticky;top:24px;padding:18px;border:1px solid #ddd;border-radius:12px;background:#fff;max-height:calc(100vh - 48px);overflow:auto}.mtgdb-sheet-head{display:none}.mtgdb-field{margin:0 0 16px}.mtgdb-field label,.mtgdb-two label{display:block;font-size:14px;font-weight:600}.mtgdb-field input[type=search],.mtgdb-field select,.mtgdb-two input,.mtgdb-inline select{box-sizing:border-box;width:100%;margin-top:6px;min-height:40px}.mtgdb-field select[multiple]{min-height:130px}.mtgdb-two{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:16px}.mtgdb-color-row{display:flex;flex-wrap:wrap;gap:6px}.mtgdb-color input,.mtgdb-check input,.mtgdb-mode input{position:absolute;opacity:0;pointer-events:none}.mtgdb-color span,.mtgdb-check span,.mtgdb-mode span{display:inline-flex;align-items:center;justify-content:center;min-height:34px;padding:0 10px;border:1px solid #ccc;border-radius:999px;cursor:pointer;font-size:13px}.mtgdb-color input:checked+span,.mtgdb-check input:checked+span,.mtgdb-mode input:checked+span{border-color:#222;background:#222;color:#fff}.mtgdb-color-exclude input:checked+span{background:#fff;color:#222;border-color:#222;box-shadow:inset 0 0 0 1px #222;text-decoration:line-through}.mtgdb-color input:focus-visible+span,.mtgdb-check input:focus-visible+span,.mtgdb-mode input:focus-visible+span{outline:2px solid currentColor;outline-offset:2px}.mtgdb-condition-label{margin-top:9px;font-size:12px}.mtgdb-mode{display:flex;flex-wrap:wrap;gap:6px;margin-top:5px}.mtgdb-check-grid{display:flex;flex-wrap:wrap;gap:6px}.mtgdb-advanced{margin:12px 0}.mtgdb-advanced summary{cursor:pointer;font-weight:700;margin-bottom:14px}.mtgdb-actions{display:grid;grid-template-columns:2fr 1fr;gap:8px;position:sticky;bottom:-18px;background:#fff;padding:12px 0 18px}.mtgdb-actions button,.mtgdb-mobile-open,.mtgdb-sheet-close{min-height:42px;border-radius:8px;border:1px solid #222;cursor:pointer}.mtgdb-submit{background:#222;color:#fff}.mtgdb-clear{background:#fff}.mtgdb-results-head{display:flex;justify-content:flex-end;margin-bottom:12px}.mtgdb-count{font-weight:700}.mtgdb-status{margin:12px 0}.mtgdb-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:18px}.mtgdb-card-image{display:block;width:100%;padding:0;border:0;background:transparent;cursor:zoom-in;border-radius:4.75%}.mtgdb-card img{display:block;width:100%;height:auto;border-radius:4.75%;box-shadow:0 2px 8px rgba(0,0,0,.16)}.mtgdb-card-name{font-size:13px;font-weight:600;line-height:1.4;margin-top:7px;text-align:center}.mtgdb-no-image{aspect-ratio:488/680;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:4.75%}.mtgdb-mobile-open,.mtgdb-backdrop{display:none}.mtgdb-stats{margin-bottom:16px}.mtgdb-stat-row{display:flex;align-items:end;gap:7px;margin-top:8px}.mtgdb-stat-row>span:first-child{width:68px;font-size:14px;font-weight:700;align-self:center}.mtgdb-stat-row label{font-size:11px;font-weight:600}.mtgdb-stat-row input{display:block;box-sizing:border-box;width:70px;min-height:38px;margin-top:4px}.mtgdb-subtype-field{position:relative}.mtgdb-subtype-search{box-sizing:border-box;width:100%;min-height:40px;margin-top:6px}.mtgdb-selected-subtypes{display:flex;flex-wrap:wrap;gap:5px;margin-top:6px}.mtgdb-selected-subtypes:empty{display:none}.mtgdb-selected-subtypes button{border:1px solid #222;border-radius:999px;background:#222;color:#fff;padding:5px 9px;cursor:pointer}.mtgdb-subtype-suggestions{position:absolute;left:0;right:0;z-index:20;max-height:250px;overflow:auto;border:1px solid #ccc;background:#fff;box-shadow:0 8px 20px rgba(0,0,0,.12)}.mtgdb-subtype-suggestions[hidden]{display:none}.mtgdb-subtype-suggestions button{display:flex;justify-content:space-between;gap:10px;width:100%;padding:9px 10px;border:0;border-bottom:1px solid #eee;background:#fff;text-align:left;cursor:pointer}.mtgdb-subtype-suggestions button:hover,.mtgdb-subtype-suggestions button:focus{background:#f3f3f3}.mtgdb-subtype-suggestions small{opacity:.55}.mtgdb-subtype-empty{padding:10px}.mtgdb-pagination{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:6px;margin:26px 0}.mtgdb-pagination[hidden]{display:none}.mtgdb-pagination button{min-width:40px;height:40px;padding:0 10px;border:1px solid #ccc;border-radius:7px;background:#fff;cursor:pointer}.mtgdb-pagination button[aria-current=page]{border-color:#222;background:#222;color:#fff;font-weight:700}.mtgdb-pagination button:disabled{opacity:.35;cursor:default}.mtgdb-lightbox{position:fixed;z-index:2147483646;inset:0;display:grid;grid-template-columns:minmax(44px,1fr) minmax(0,720px) minmax(44px,1fr);align-items:center;background:rgba(0,0,0,.88);padding:56px 12px 24px}.mtgdb-lightbox[hidden]{display:none}.mtgdb-lightbox-main{text-align:center;color:#fff;min-width:0}.mtgdb-lightbox-main img{display:block;max-width:100%;max-height:calc(100vh - 145px);width:auto;height:auto;margin:auto;border-radius:4.75%}.mtgdb-lightbox-name{margin-top:10px;font-weight:700}.mtgdb-lightbox-position{margin-top:3px;font-size:12px;opacity:.75}.mtgdb-lightbox-close,.mtgdb-lightbox-prev,.mtgdb-lightbox-next{border:0;background:rgba(0,0,0,.35);color:#fff;cursor:pointer}.mtgdb-lightbox-close{position:absolute;right:16px;top:12px;width:44px;height:44px;border-radius:50%;font-size:28px}.mtgdb-lightbox-prev,.mtgdb-lightbox-next{justify-self:center;width:44px;height:60px;border-radius:8px;font-size:42px;line-height:1}.mtgdb-lightbox-prev:disabled,.mtgdb-lightbox-next:disabled{opacity:.2;cursor:default}.mtgdb-no-scroll{overflow:hidden}
@media(max-width:782px){.mtgdb-layout{display:block}.mtgdb-panel{position:fixed;z-index:2147483645;left:0;right:0;bottom:0;top:auto;max-height:min(88dvh,820px);border-radius:18px 18px 0 0;padding:16px 16px calc(16px + env(safe-area-inset-bottom));transform:translateY(105%);transition:transform .2s ease;box-shadow:0 -8px 30px rgba(0,0,0,.2)}.is-sheet-open .mtgdb-panel{transform:translateY(0)}.mtgdb-sheet-head{display:flex;align-items:center;justify-content:space-between;position:sticky;top:-16px;background:#fff;z-index:30;padding:8px 0 12px}.mtgdb-sheet-head strong{font-size:18px}.mtgdb-sheet-close{width:42px;background:#fff;font-size:24px}.mtgdb-mobile-open{display:block;position:fixed;z-index:99999;left:50%;bottom:calc(14px + env(safe-area-inset-bottom));transform:translateX(-50%);width:min(72vw,320px);padding:0 28px;background:#222;color:#fff;box-shadow:0 4px 16px rgba(0,0,0,.25)}.mtgdb-backdrop{display:block;position:fixed;z-index:2147483644;inset:0;background:rgba(0,0,0,.42)}.mtgdb-backdrop[hidden]{display:none}.mtgdb-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.mtgdb-card-name{font-size:12px}.mtgdb-results{padding-bottom:76px}.mtgdb-stat-row>span:first-child{width:64px}.mtgdb-stat-row input{width:62px}.mtgdb-lightbox{grid-template-columns:44px minmax(0,1fr) 44px;padding:58px 4px 20px}.mtgdb-lightbox-main img{max-height:calc(100dvh - 150px)}.mtgdb-lightbox-prev,.mtgdb-lightbox-next{width:40px;height:54px;font-size:36px}.mtgdb-pagination{gap:4px}.mtgdb-pagination button{min-width:36px;height:38px;padding:0 8px}}
@media(min-width:1200px){.mtgdb-grid{grid-template-columns:repeat(auto-fill,minmax(190px,1fr))}}
/* v0.4.2 public display settings */
.mtgdb-search-app{--mtgdb-columns:5;--mtgdb-card-gap:12px;--mtgdb-sticky-offset:24px}.mtgdb-panel{top:var(--mtgdb-sticky-offset);max-height:calc(100vh - var(--mtgdb-sticky-offset) - 16px)}.mtgdb-no-sticky .mtgdb-panel{position:static;max-height:none}.mtgdb-grid{grid-template-columns:repeat(var(--mtgdb-columns),minmax(0,1fr));gap:var(--mtgdb-card-gap)}.mtgdb-card{container-type:inline-size;min-width:0}.mtgdb-card-name{font-size:clamp(8px,8cqi,13px);overflow-wrap:anywhere}.mtgdb-hide-card-name .mtgdb-card-name{display:none}.mtgdb-results-head{align-items:center;justify-content:space-between;gap:12px}.mtgdb-column-controls{display:flex;align-items:center;flex-wrap:wrap;gap:5px;font-size:12px}.mtgdb-column-controls button{min-width:38px;padding:5px 7px;border:1px solid #ccc;border-radius:6px;background:#fff;cursor:pointer;font-size:12px}.mtgdb-column-controls button[aria-pressed=true]{background:#222;color:#fff;border-color:#222}.mtgdb-lightbox-text{max-width:680px;margin:14px auto 0;padding:12px 14px;border-radius:8px;background:rgba(255,255,255,.1);color:#fff;text-align:left;white-space:pre-line;line-height:1.65;font-size:14px}.mtgdb-lightbox-text[hidden]{display:none}.mtgdb-lightbox-main img{max-height:calc(100vh - 110px)}
@media(max-width:782px){.mtgdb-panel{top:auto;max-height:min(92dvh,900px)}.mtgdb-mobile-open{width:min(84vw,360px)}.mtgdb-grid{grid-template-columns:repeat(var(--mtgdb-columns),minmax(0,1fr));gap:var(--mtgdb-card-gap)}.mtgdb-advanced>summary{display:none}.mtgdb-advanced>.mtgdb-advanced-body{display:block!important}.mtgdb-advanced{display:block;margin:0}.mtgdb-results-head{align-items:flex-end}.mtgdb-column-controls{max-width:75%}.mtgdb-lightbox-main{max-height:calc(100dvh - 90px);overflow:auto}.mtgdb-lightbox-main img{max-height:calc(100dvh - 110px)}.mtgdb-lightbox-text{font-size:13px;margin-left:4px;margin-right:4px}}
@media(min-width:1200px){.mtgdb-grid{grid-template-columns:repeat(var(--mtgdb-columns),minmax(0,1fr))}}

/* v0.4.3: compact configurable search panel + mobile header clearance */
.mtgdb-search-app{--mtgdb-panel-width:250px;--mtgdb-mobile-panel-offset:0px}
.mtgdb-layout{grid-template-columns:minmax(180px,var(--mtgdb-panel-width)) minmax(0,1fr)}
.mtgdb-panel{padding:14px}.mtgdb-field{margin-bottom:12px}.mtgdb-two{margin-bottom:12px}.mtgdb-actions{padding-top:9px}.mtgdb-color span,.mtgdb-check span,.mtgdb-mode span{min-height:32px;padding-left:9px;padding-right:9px}.mtgdb-field input[type=search],.mtgdb-field select,.mtgdb-two input,.mtgdb-inline select{min-height:36px}
@media(max-width:782px){.mtgdb-panel{top:var(--mtgdb-mobile-panel-offset);bottom:0;max-height:calc(100dvh - var(--mtgdb-mobile-panel-offset));padding-top:16px}.mtgdb-sheet-head{top:-16px}}

/* v0.4.6: denser panel, compact column selector, card-name copy UI */
.mtgdb-layout{grid-template-columns:minmax(150px,var(--mtgdb-panel-width)) minmax(0,1fr)}
.mtgdb-column-controls{display:flex;align-items:center;font-size:12px;white-space:nowrap}
.mtgdb-column-controls label{display:flex;align-items:center;gap:5px}
.mtgdb-column-select{width:auto;min-width:68px;min-height:30px;padding:2px 24px 2px 7px;font-size:12px}
.mtgdb-card-name{display:block;box-sizing:border-box;width:100%;margin:3px 0 0;padding:0;border:0;background:transparent;color:inherit;font:inherit;font-weight:600;line-height:1.35;text-align:center;cursor:copy;font-size:clamp(10px,10cqi,14px);overflow-wrap:normal;word-break:normal;line-break:strict}
.mtgdb-card-name:hover{text-decoration:underline;text-underline-offset:2px}.mtgdb-card-name.is-copied{font-weight:700}
@media(min-width:783px){
  .mtgdb-panel{padding:10px;font-size:12px}
  .mtgdb-field{margin-bottom:9px}.mtgdb-two{gap:6px;margin-bottom:9px}.mtgdb-advanced{margin:8px 0}.mtgdb-advanced summary{margin-bottom:9px;font-size:12px}
  .mtgdb-field label,.mtgdb-two label,.mtgdb-field legend{font-size:12px}.mtgdb-condition-label{margin-top:6px;font-size:10px}
  .mtgdb-field input[type=search],.mtgdb-field select,.mtgdb-two input,.mtgdb-inline select,.mtgdb-subtype-search{min-height:31px;margin-top:4px;font-size:12px;padding-top:3px;padding-bottom:3px}
  .mtgdb-color-row,.mtgdb-check-grid,.mtgdb-mode{gap:4px}.mtgdb-color span,.mtgdb-check span,.mtgdb-mode span{min-height:27px;padding:0 7px;font-size:11px;white-space:nowrap}
  .mtgdb-stats{margin-bottom:9px}.mtgdb-stat-row{display:grid;grid-template-columns:minmax(48px,auto) minmax(0,1fr) 10px minmax(0,1fr);align-items:end;gap:4px;margin-top:5px}.mtgdb-stat-row>span:first-child{width:auto;min-width:0;font-size:11px;white-space:nowrap}.mtgdb-stat-row label{min-width:0;font-size:9px;white-space:nowrap}.mtgdb-stat-row input{box-sizing:border-box;width:100%;min-width:0;min-height:29px;margin-top:2px;padding:2px 4px;font-size:11px}
  .mtgdb-actions{grid-template-columns:minmax(0,2fr) auto;gap:5px;bottom:-10px;padding:8px 0 10px}.mtgdb-actions button{min-height:32px;padding:3px 8px;font-size:11px;white-space:nowrap;word-break:keep-all}.mtgdb-clear{min-width:48px}
}
@media(max-width:782px){
  .mtgdb-sheet-close{width:44px;min-height:44px;padding:0;border:0!important;border-radius:0!important;background:transparent!important;box-shadow:none!important;font-size:30px;font-weight:800;line-height:1;color:#222}
  .mtgdb-sheet-close:hover,.mtgdb-sheet-close:focus{background:transparent!important}
  .mtgdb-card-name{font-size:clamp(10px,10cqi,14px);margin-top:3px}
}

/* v0.5.8: double-faced card flip controls and iPhone-safe mobile search button. */
.mtgdb-card-image-wrap{position:relative}.mtgdb-face-toggle{position:absolute;right:7px;bottom:7px;z-index:3;width:34px;height:34px;padding:0;border:1px solid rgba(255,255,255,.8);border-radius:50%;background:rgba(0,0,0,.72);color:#fff;font-size:21px;line-height:1;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,.25)}.mtgdb-lightbox-face-toggle{margin:10px auto 0;min-height:40px;padding:7px 14px;border:1px solid rgba(255,255,255,.65);border-radius:999px;background:rgba(0,0,0,.42);color:#fff;cursor:pointer}.mtgdb-lightbox-face-toggle[hidden]{display:none}
@media(max-width:782px){.mtgdb-mobile-open{bottom:calc(64px + env(safe-area-inset-bottom))}.mtgdb-results{padding-bottom:126px}}

/* v0.5.9: precise flip centering + iOS Safari visual-viewport clearance. */
.mtgdb-face-toggle{display:flex;align-items:center;justify-content:center;line-height:1;font-family:Arial,sans-serif;text-align:center;text-indent:0}
@media(max-width:782px){
  .mtgdb-search-app{--mtgdb-vv-bottom:0px;--mtgdb-vv-height:100dvh}
  .mtgdb-mobile-open{bottom:calc(64px + env(safe-area-inset-bottom) + var(--mtgdb-vv-bottom))}
  .mtgdb-panel{bottom:var(--mtgdb-vv-bottom);max-height:calc(var(--mtgdb-vv-height) - var(--mtgdb-mobile-panel-offset));overflow:hidden;display:flex;flex-direction:column}
  .mtgdb-panel .mtgdb-form{overflow-y:auto;overscroll-behavior:contain;padding-bottom:calc(84px + env(safe-area-inset-bottom));-webkit-overflow-scrolling:touch}
  .mtgdb-actions{bottom:0;z-index:35;padding-bottom:calc(14px + env(safe-area-inset-bottom))}
  .mtgdb-lightbox{box-sizing:border-box;padding-top:calc(68px + env(safe-area-inset-top));padding-bottom:calc(20px + env(safe-area-inset-bottom))}
  .mtgdb-lightbox-close{top:calc(12px + env(safe-area-inset-top));display:flex;align-items:center;justify-content:center;line-height:1}
  .mtgdb-lightbox-main{max-height:calc(100% - 12px)}
  .mtgdb-lightbox-main img{max-height:calc(100% - 62px)}
}


/* v0.5.10: opaque mobile action dock, image-anchored lightbox close, uniform card sizing. */
.mtgdb-lightbox-main{position:relative}
.mtgdb-lightbox-image-wrap{position:relative;width:min(100%,560px);margin:0 auto}
.mtgdb-lightbox-image-wrap img{width:100%;height:auto;max-width:none;object-fit:contain}
.mtgdb-lightbox-close{position:absolute;z-index:5;right:-8px;top:-8px;display:flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:50%;font-size:28px;line-height:1;background:rgba(0,0,0,.72);color:#fff}
@media(max-width:782px){
  .mtgdb-actions{box-shadow:0 18px 0 18px #fff;background:#fff}
  .mtgdb-panel .mtgdb-form{background:#fff}
  .mtgdb-lightbox-image-wrap{width:100%;max-height:calc(100% - 62px)}
  .mtgdb-lightbox-image-wrap img{width:100%;max-height:calc(var(--mtgdb-vv-height) - 170px);object-fit:contain}
  .mtgdb-lightbox-close{right:0;top:0;transform:translate(35%,-35%)}
}


/* v0.5.11: final mobile positioning polish. */
@media(max-width:782px){
  .mtgdb-mobile-open{bottom:calc(14px + env(safe-area-inset-bottom) + var(--mtgdb-vv-bottom))}
  .mtgdb-results{padding-bottom:82px}
  .mtgdb-actions{position:sticky;z-index:35;background:#fff;box-shadow:none}
  .mtgdb-actions::after{content:"";position:absolute;z-index:0;left:-20px;right:-20px;top:100%;height:100vh;background:#fff;pointer-events:none}
  .mtgdb-actions button{position:relative;z-index:1}
  .mtgdb-lightbox-close{width:38px;height:38px;right:-40px;top:-40px;transform:none;font-size:26px}
}

/* v0.5.12: keep the whole card visible and place close just outside its top-right corner. */
@media(max-width:782px){
  .mtgdb-lightbox{overflow:visible}
  .mtgdb-lightbox-main{overflow:visible;max-height:none}
  .mtgdb-lightbox-image-wrap{display:inline-block;width:auto;max-width:100%;max-height:none;vertical-align:top}
  .mtgdb-lightbox-image-wrap img{display:block;width:auto;height:calc(var(--mtgdb-vv-height) - 190px);max-width:100%;max-height:calc(var(--mtgdb-vv-height) - 190px);object-fit:contain;margin:0 auto}
  .mtgdb-lightbox-close{right:-32px;top:-32px;transform:none}
}


/* v0.5.13: mobile sheet structure, safer trigger position, exact result scroll target, lightbox fit. */
@media(max-width:782px){
  .mtgdb-search-app,.mtgdb-panel,.mtgdb-form,.mtgdb-form-scroll{max-width:100%;overflow-x:hidden;box-sizing:border-box}
  .mtgdb-mobile-open{bottom:calc(64px + env(safe-area-inset-bottom) + var(--mtgdb-vv-bottom))}
  .mtgdb-results{padding-bottom:126px}
  .mtgdb-panel{overflow:hidden}
  .mtgdb-panel .mtgdb-form{display:flex;flex-direction:column;min-height:0;height:100%;overflow:hidden;padding-bottom:0;background:#fff}
  .mtgdb-form-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;overscroll-behavior-x:none;-webkit-overflow-scrolling:touch;padding-bottom:12px;touch-action:pan-y}
  .mtgdb-actions{position:relative;flex:0 0 auto;bottom:auto;z-index:35;margin:0;padding:10px 0 calc(14px + env(safe-area-inset-bottom));background:#fff;box-shadow:none}
  .mtgdb-actions::after{display:none}
  .mtgdb-lightbox{overflow:hidden}
  .mtgdb-lightbox-main{overflow:visible;max-width:calc(100% - 52px);margin-left:auto;margin-right:auto}
  .mtgdb-lightbox-image-wrap{display:inline-block;width:auto;max-width:100%;max-height:none;vertical-align:top}
  .mtgdb-lightbox-image-wrap img{display:block;width:auto;height:calc(var(--mtgdb-vv-height) - 190px);max-width:100%;max-height:calc(var(--mtgdb-vv-height) - 190px);object-fit:contain;margin:0 auto}
  .mtgdb-lightbox-close{right:-34px;top:-28px;transform:none}
}


/* v0.5.14: configurable mobile trigger clearance, guaranteed-visible lightbox close, result header clearance. */
@media(max-width:782px){
  .mtgdb-mobile-open{bottom:calc(var(--mtgdb-mobile-button-bottom,64px) + env(safe-area-inset-bottom) + var(--mtgdb-vv-bottom))}
  .mtgdb-lightbox-main{max-width:100%;overflow:visible}
  .mtgdb-lightbox-image-wrap{box-sizing:border-box;padding:42px 42px 0 0;max-width:100%;overflow:visible}
  .mtgdb-lightbox-image-wrap img{height:calc(var(--mtgdb-vv-height) - 232px);max-height:calc(var(--mtgdb-vv-height) - 232px);max-width:calc(100vw - 78px)}
  .mtgdb-lightbox-close{right:0;top:0;transform:none;display:flex;visibility:visible;opacity:1}
}


/* v0.5.15: close mark hugs the card corner without a circle; pagination uses JS occlusion correction. */
@media(max-width:782px){
  .mtgdb-lightbox-image-wrap{padding:24px 24px 0 0}
  .mtgdb-lightbox-image-wrap img{height:calc(var(--mtgdb-vv-height) - 214px);max-height:calc(var(--mtgdb-vv-height) - 214px);max-width:calc(100vw - 60px)}
  .mtgdb-lightbox-close{right:2px;top:0;width:28px;height:28px;padding:0;border-radius:0;background:transparent;box-shadow:none;font-size:30px;font-weight:400;line-height:1;color:#fff;text-shadow:0 1px 4px rgba(0,0,0,.9)}
}
\n\n

/* v0.5.17: restore the proven mobile lightbox layout; only the close mark is positioned outside the card by JS. */
@media(max-width:782px){
  .mtgdb-lightbox{
    display:grid;
    grid-template-columns:44px minmax(0,1fr) 44px;
    align-items:center;
    box-sizing:border-box;
    padding:58px 4px 20px;
    overflow:hidden;
  }
  .mtgdb-lightbox-main{
    position:relative;
    min-width:0;
    width:auto;
    max-width:none;
    max-height:calc(100% - 12px);
    margin:0;
    overflow:visible;
    text-align:center;
  }
  .mtgdb-lightbox-image-wrap{
    position:relative;
    display:block;
    width:100%;
    max-width:100%;
    max-height:calc(100% - 62px);
    margin:0 auto;
    padding:0;
    overflow:visible;
  }
  .mtgdb-lightbox-image-wrap img{
    display:block;
    width:100%;
    height:auto;
    max-width:none;
    max-height:calc(var(--mtgdb-vv-height) - 170px);
    margin:0 auto;
    object-fit:contain;
  }
  .mtgdb-lightbox-close{
    position:fixed;
    z-index:2147483647;
    right:auto;
    bottom:auto;
    width:30px;
    height:30px;
    padding:0;
    border:0;
    border-radius:0;
    background:transparent;
    box-shadow:none;
    color:#fff;
    font-size:31px;
    font-weight:400;
    line-height:1;
    text-shadow:0 1px 4px rgba(0,0,0,.95);
    transform:none;
    display:flex;
    align-items:center;
    justify-content:center;
    visibility:visible;
    opacity:1;
  }
  .mtgdb-lightbox-prev,.mtgdb-lightbox-next{
    position:static;
    justify-self:center;
    width:40px;
    height:54px;
    margin:0;
    transform:none;
    font-size:36px;
  }
}


/* v0.5.18: restore v0.5.10 mobile lightbox geometry exactly; only move the close mark outside the image. */
@media(max-width:782px){
  .mtgdb-lightbox{
    display:grid;
    grid-template-columns:44px minmax(0,1fr) 44px;
    align-items:center;
    padding:58px 4px 20px;
    overflow:visible;
  }
  .mtgdb-lightbox-main{
    position:relative;
    min-width:0;
    width:auto;
    max-width:none;
    max-height:calc(100dvh - 90px);
    margin:0;
    overflow:auto;
    text-align:center;
    color:#fff;
  }
  .mtgdb-lightbox-image-wrap{
    position:relative;
    display:block;
    width:100%;
    max-width:100%;
    max-height:calc(100% - 62px);
    margin:0 auto;
    padding:0;
    overflow:visible;
  }
  .mtgdb-lightbox-image-wrap img{
    display:block;
    width:100%;
    height:auto;
    max-width:none;
    max-height:calc(var(--mtgdb-vv-height) - 170px);
    margin:0 auto;
    object-fit:contain;
  }
  .mtgdb-lightbox-close{
    position:absolute;
    z-index:5;
    right:0;
    top:0;
    left:auto;
    bottom:auto;
    width:36px;
    height:36px;
    padding:0;
    border:0;
    border-radius:0;
    background:transparent;
    box-shadow:none;
    color:#fff;
    font-size:30px;
    font-weight:400;
    line-height:1;
    text-shadow:0 1px 4px rgba(0,0,0,.95);
    transform:translate(72%,-72%);
    display:flex;
    align-items:center;
    justify-content:center;
    visibility:visible;
    opacity:1;
  }
  .mtgdb-lightbox-prev,.mtgdb-lightbox-next{
    justify-self:center;
    position:static;
    width:40px;
    height:54px;
    margin:0;
    transform:none;
    font-size:36px;
  }
}


/* v0.5.19: Image Gallery-style lightbox geometry. Navigation and close controls
   are overlay-positioned and never participate in the card width calculation. */
.mtgdb-lightbox{
  position:fixed;
  inset:0;
  z-index:2147483646;
  display:flex;
  align-items:center;
  justify-content:center;
  box-sizing:border-box;
  padding:60px 20px 20px;
  overflow:hidden;
  background:rgba(0,0,0,.9);
}
.mtgdb-lightbox[hidden]{display:none}
.mtgdb-lightbox-main{
  position:relative;
  width:min(90vw,1200px);
  max-width:none;
  max-height:none;
  margin:0;
  overflow:visible;
  text-align:center;
  color:#fff;
  min-width:0;
}
.mtgdb-lightbox-image-wrap{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  height:min(72vh,900px);
  max-width:none;
  max-height:none;
  margin:0;
  padding:0;
  overflow:hidden;
  box-sizing:border-box;
}
.mtgdb-lightbox-image-wrap img{
  display:block;
  width:100%;
  height:100%;
  max-width:none;
  max-height:none;
  margin:0;
  object-fit:contain;
}
.mtgdb-lightbox-prev,.mtgdb-lightbox-next{
  position:absolute;
  top:50%;
  z-index:2147483647;
  width:auto;
  height:auto;
  margin:0;
  padding:20px;
  border:0;
  border-radius:0;
  background:rgba(255,255,255,.1);
  color:#fff;
  font-size:40px;
  line-height:1;
  transform:translateY(-50%);
  cursor:pointer;
}
.mtgdb-lightbox-prev{left:10px}
.mtgdb-lightbox-next{right:10px}
.mtgdb-lightbox-close{
  position:absolute;
  top:16px;
  right:16px;
  left:auto;
  bottom:auto;
  z-index:2147483647;
  display:flex;
  align-items:center;
  justify-content:center;
  width:48px;
  height:48px;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  color:#fff;
  font-size:34px;
  font-weight:400;
  line-height:1;
  text-shadow:none;
  transform:none;
  cursor:pointer;
  visibility:visible;
  opacity:1;
}
@media(max-width:782px){
  .mtgdb-lightbox{
    display:flex;
    grid-template-columns:none;
    padding:60px 20px 20px;
    overflow:hidden;
  }
  .mtgdb-lightbox-main{
    width:92vw;
    max-width:92vw;
    max-height:none;
    margin:0;
    overflow:visible;
  }
  .mtgdb-lightbox-image-wrap{
    display:flex;
    width:92vw;
    max-width:92vw;
    height:min(70vh,calc(var(--mtgdb-vv-height) - 190px));
    max-height:none;
    margin:0;
    padding:0;
    overflow:hidden;
  }
  .mtgdb-lightbox-image-wrap img{
    width:100%;
    height:100%;
    max-width:none;
    max-height:none;
    margin:0;
    object-fit:contain;
  }
  .mtgdb-lightbox-prev,.mtgdb-lightbox-next{
    position:absolute;
    top:50%;
    width:auto;
    height:auto;
    padding:12px;
    margin:0;
    font-size:30px;
    transform:translateY(-50%);
  }
  .mtgdb-lightbox-prev{left:10px}
  .mtgdb-lightbox-next{right:10px}
  .mtgdb-lightbox-close{
    position:absolute;
    top:10px;
    right:10px;
    width:42px;
    height:42px;
    padding:0;
    font-size:30px;
    transform:none;
  }
}


/* v0.5.20: mobile lightbox breathing room. Keep the v0.5.19 Gallery-style
   overlay/navigation geometry, but render the card at 90% of that stage and
   center it vertically. The close mark sits just outside the card's top-right. */
@media(max-width:782px){
  .mtgdb-lightbox{
    padding:20px 20px;
    align-items:center;
    justify-content:center;
  }
  .mtgdb-lightbox-main{
    width:82.8vw;
    max-width:82.8vw;
    margin:0;
  }
  .mtgdb-lightbox-image-wrap{
    width:82.8vw;
    max-width:82.8vw;
    height:min(63vh,calc((var(--mtgdb-vv-height) - 190px) * .90));
    margin:0;
    overflow:visible;
  }
  .mtgdb-lightbox-image-wrap img{
    width:100%;
    height:100%;
    max-width:100%;
    max-height:100%;
    object-fit:contain;
  }
  .mtgdb-lightbox-close{
    top:50%;
    right:calc(8.6vw - 4px);
    width:36px;
    height:36px;
    font-size:30px;
    transform:translateY(calc(-31.5vh - 22px));
    background:transparent;
    border-radius:0;
  }
}

/* v0.5.23: move the accepted v0.5.22 mobile lightbox group 50px upward.
   Preserve 90% card sizing, close position relationship, and Gallery-style geometry. */
@media(max-width:782px){
  .mtgdb-lightbox-main{
    transform:translateY(60px);
  }
  .mtgdb-lightbox-prev,.mtgdb-lightbox-next{
    top:calc(50% + 60px);
  }
  .mtgdb-lightbox-close{
    top:calc(50% + 60px);
  }
}


/* v0.5.26: mobile browser zoom hardening.
   - iOS Safari must not auto-zoom form controls on focus.
   - Off-canvas search UI must stay off-canvas during a manual page zoom.
   - Browser pinch zoom must not be reinterpreted as a VisualViewport layout resize. */
@media(max-width:782px){
  .mtgdb-form input[type=search],
  .mtgdb-form input[type=text],
  .mtgdb-form input[type=number],
  .mtgdb-form input[type=url],
  .mtgdb-form input[type=email],
  .mtgdb-form input:not([type]),
  .mtgdb-form select,
  .mtgdb-form textarea,
  .mtgdb-subtype-search{font-size:16px!important}
  .mtgdb-search-app.is-visual-zoomed:not(.is-sheet-open) .mtgdb-panel{
    visibility:hidden!important;pointer-events:none!important
  }
  .mtgdb-search-app.is-visual-zoomed .mtgdb-mobile-open{
    visibility:hidden!important;pointer-events:none!important;opacity:0!important
  }
}

/* v0.5.28: lightweight pagination loading feedback; no card/layout replacement. */
.mtgdb-pagination.is-loading{position:relative;pointer-events:none}
.mtgdb-pagination.is-loading::after{content:'読み込み中…';position:absolute;top:calc(100% + 5px);left:50%;transform:translateX(-50%);white-space:nowrap;font-size:12px;font-weight:600;opacity:.72}
.mtgdb-pagination.is-loading button{opacity:.45}

/* v0.5.29: admin-only visible performance diagnostics. */
.mtgdb-speed-diagnostic{margin:18px 0;padding:10px 12px;border:1px dashed #b8b8b8;border-radius:8px;background:#fafafa;font-size:13px}.mtgdb-speed-diagnostic summary{cursor:pointer;font-weight:700}.mtgdb-speed-diagnostic-body{margin-top:10px}.mtgdb-speed-diagnostic table{border-collapse:collapse;width:100%;max-width:520px}.mtgdb-speed-diagnostic th,.mtgdb-speed-diagnostic td{padding:5px 8px;border-bottom:1px solid #e2e2e2;text-align:left}.mtgdb-speed-diagnostic th{width:180px}.mtgdb-speed-diagnostic p{margin:10px 0 0}


/* v0.5.31: desktop lightbox hit area/close button and mobile search-button range. */
@media(min-width:783px){
  .mtgdb-lightbox-main{width:min(680px,calc(100vw - 180px));max-width:min(680px,calc(100vw - 180px))}
  .mtgdb-lightbox-image-wrap{width:min(calc(72vh * .716),100%);max-width:100%;margin-left:auto;margin-right:auto}
  .mtgdb-search-app .mtgdb-lightbox-close{position:fixed!important;top:16px!important;right:16px!important;left:auto!important;display:flex!important;visibility:visible!important;opacity:1!important;z-index:2147483647!important;color:#fff!important;background:transparent!important}
  body.admin-bar .mtgdb-search-app .mtgdb-lightbox-close{top:48px!important}
}
@media(max-width:782px){
  .mtgdb-mobile-open{visibility:hidden;pointer-events:none;opacity:0}
  .mtgdb-search-app.is-mobile-range-active .mtgdb-mobile-open{visibility:visible;pointer-events:auto;opacity:1}
  .mtgdb-search-app.is-visual-zoomed .mtgdb-mobile-open{visibility:hidden!important;pointer-events:none!important;opacity:0!important}
}

/* v0.5.33: mobile search button leaves the active range when the DB block bottom rises above 70% of the viewport. */


/* v1.0.1: lightbox rules/description text overlays the card image so text never reduces card geometry. */
.mtgdb-lightbox-image-wrap{position:relative}
.mtgdb-lightbox-image-wrap .mtgdb-lightbox-text{
  box-sizing:border-box;position:absolute;z-index:3;left:4%;right:4%;bottom:4%;
  max-width:none;max-height:48%;margin:0;padding:10px 12px;overflow:auto;
  border-radius:8px;background:rgba(0,0,0,.72);color:#fff;text-align:left;
  white-space:pre-line;line-height:1.6;font-size:14px;box-shadow:0 2px 10px rgba(0,0,0,.25)
}
@media(max-width:782px){
  .mtgdb-lightbox-image-wrap .mtgdb-lightbox-text{left:3%;right:3%;bottom:3%;max-height:46%;margin:0;font-size:13px;padding:9px 10px}
}


/* v1.0.23: administrator-only browser-local deck builder beta mobile header clearance. */
.mtgdb-deck-add{display:block;width:100%;margin-top:7px;padding:6px 8px;border:1px solid #b8b8b8;border-radius:6px;background:#fff;cursor:pointer;font-size:12px;font-weight:700}.mtgdb-deck-add:hover{background:#f4f4f4}
.mtgdb-results-head .mtgdb-deck-open{flex:0 0 auto;padding:8px 12px;border:1px solid #333;border-radius:7px;background:#222;color:#fff;cursor:pointer;font-size:13px;font-weight:700;line-height:1.3}.mtgdb-deck-open-count{margin-left:5px;opacity:.82}
.mtgdb-deck-backdrop[hidden],.mtgdb-deck-drawer[hidden]{display:none!important}.mtgdb-deck-backdrop{position:fixed;z-index:99992;inset:0;background:rgba(0,0,0,.34)}.mtgdb-deck-drawer{box-sizing:border-box;position:fixed;z-index:99993;top:0;right:0;width:min(480px,94vw);height:100vh;background:#fff;box-shadow:-8px 0 28px rgba(0,0,0,.2);overflow:hidden;display:flex;flex-direction:column}body.admin-bar .mtgdb-deck-drawer{top:32px;height:calc(100vh - 32px)}
.mtgdb-deck-head{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border-bottom:1px solid #ddd}.mtgdb-deck-head>div{display:flex;flex-direction:column}.mtgdb-deck-head small{margin-top:2px;font-size:11px;opacity:.65}.mtgdb-deck-close{border:0;background:transparent;font-size:28px;line-height:1;cursor:pointer}
.mtgdb-deck-actions{flex:0 0 auto;display:grid;grid-template-columns:1fr auto;gap:8px;padding:10px 16px;border-bottom:1px solid #ddd;background:#fff}.mtgdb-deck-actions button{padding:9px 11px;border:1px solid #aaa;border-radius:6px;background:#fff;cursor:pointer;font-weight:700}.mtgdb-deck-copy{background:#222!important;color:#fff!important;border-color:#222!important}.mtgdb-deck-clear{font-size:12px}
.mtgdb-deck-body{flex:1 1 auto;min-height:0;overflow:auto;padding:12px 16px 28px}.mtgdb-deck-section+.mtgdb-deck-section{margin-top:22px}.mtgdb-deck-section h3{display:flex;justify-content:space-between;margin:0 0 9px;font-size:16px}.mtgdb-deck-section h3 span{font-weight:400;opacity:.7}.mtgdb-deck-empty{margin:8px 0;color:#777;font-size:13px}.mtgdb-deck-row{display:grid;grid-template-columns:38px minmax(0,1fr) auto;gap:8px;align-items:center;padding:7px 0;border-bottom:1px solid #eee}.mtgdb-deck-row img{width:38px;height:53px;object-fit:cover;border-radius:3px}.mtgdb-deck-row-name{min-width:0;display:flex;flex-direction:column}.mtgdb-deck-row-name strong,.mtgdb-deck-row-name small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mtgdb-deck-row-name strong{font-size:13px}.mtgdb-deck-row-name small{font-size:10px;opacity:.6}.mtgdb-deck-qty{display:flex;align-items:center;gap:5px}.mtgdb-deck-qty button{width:28px;height:28px;padding:0;border:1px solid #bbb;border-radius:5px;background:#fff;cursor:pointer}.mtgdb-deck-qty span{min-width:18px;text-align:center;font-weight:700}.mtgdb-deck-move{grid-column:2/4;justify-self:end;padding:3px 7px;border:0;background:transparent;text-decoration:underline;cursor:pointer;font-size:11px;opacity:.7}.mtgdb-deck-no-scroll{overflow:hidden}
@media(max-width:782px){.mtgdb-deck-drawer{top:150px;width:100vw;height:calc(100dvh - 150px)}body.admin-bar .mtgdb-deck-drawer{top:150px;height:calc(100dvh - 150px)}.mtgdb-results-head{align-items:center;gap:8px;flex-wrap:wrap}.mtgdb-results-head .mtgdb-deck-open{order:3;flex:1 0 100%;width:100%;margin-top:2px;padding:9px 10px}.mtgdb-deck-head{padding:10px 12px}.mtgdb-deck-actions{padding:9px 12px}.mtgdb-deck-body{padding:10px 12px calc(24px + env(safe-area-inset-bottom,0px))}.mtgdb-deck-row{grid-template-columns:34px minmax(0,1fr) auto}.mtgdb-deck-row img{width:34px;height:48px}}

/* v1.0.26: stable mobile search sheet geometry.
   Use the dynamic viewport directly instead of VisualViewport-derived sheet height.
   Keep the action row at the bottom so filter changes cannot leave a blank area below it. */
@media(max-width:782px){
  .mtgdb-panel{
    top:var(--mtgdb-mobile-panel-offset,0px);
    bottom:auto;
    height:calc(100dvh - var(--mtgdb-mobile-panel-offset,0px));
    max-height:none;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }
  .mtgdb-sheet-head{flex:0 0 auto}
  .mtgdb-panel .mtgdb-form{
    flex:1 1 auto;
    min-height:0;
    height:auto;
    max-height:none;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }
  .mtgdb-form-scroll{flex:1 1 auto;min-height:0;overflow-y:auto}
  .mtgdb-actions{flex:0 0 auto;margin-top:auto}
}


/* v1.0.27: mobile search sheet stability.
   Remove nested flex/scroll geometry from the mobile sheet. The sheet itself is
   the single scroll container; header/actions stay sticky inside it. This avoids
   Android Chrome leaving a large phantom white area after checkbox/radio taps. */
@media(max-width:782px){
  .mtgdb-panel{
    top:auto!important;
    bottom:var(--mtgdb-vv-bottom,0px)!important;
    height:auto!important;
    max-height:calc(100dvh - var(--mtgdb-mobile-panel-offset,0px) - var(--mtgdb-vv-bottom,0px))!important;
    display:block!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;
  }
  .mtgdb-sheet-head{
    position:sticky!important;
    top:-16px!important;
    z-index:40!important;
    background:#fff!important;
  }
  .mtgdb-panel .mtgdb-form{
    display:block!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
    padding-bottom:0!important;
  }
  .mtgdb-form-scroll{
    display:block!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
    padding-bottom:0!important;
  }
  .mtgdb-actions{
    position:sticky!important;
    bottom:0!important;
    z-index:40!important;
    margin:0!important;
    padding:10px 0 calc(14px + env(safe-area-inset-bottom))!important;
    background:#fff!important;
  }
  .mtgdb-actions::after{display:none!important;content:none!important}
}

/* v1.0.28: administrator deck builder paste import. */
.mtgdb-deck-actions{grid-template-columns:1fr 1fr auto}
.mtgdb-deck-import{flex:0 0 auto;padding:12px 16px;border-bottom:1px solid #ddd;background:#f8f8f8}
.mtgdb-deck-import[hidden]{display:none!important}
.mtgdb-deck-import label{display:block;font-size:13px}
.mtgdb-deck-import textarea{display:block;width:100%;box-sizing:border-box;margin-top:7px;padding:9px;border:1px solid #aaa;border-radius:6px;background:#fff;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;resize:vertical}
.mtgdb-deck-import-buttons{display:flex;gap:8px;margin-top:8px}.mtgdb-deck-import-buttons button{padding:8px 12px;border:1px solid #aaa;border-radius:6px;background:#fff;font-weight:700;cursor:pointer}.mtgdb-deck-import-run{background:#222!important;color:#fff!important;border-color:#222!important}.mtgdb-deck-import-run:disabled{opacity:.55;cursor:wait}
.mtgdb-deck-import-result{margin-top:8px;white-space:pre-wrap;font-size:12px;line-height:1.5}.mtgdb-deck-import-result.is-error{color:#a00}
@media(max-width:782px){.mtgdb-deck-actions{grid-template-columns:1fr 1fr}.mtgdb-deck-clear{grid-column:1/3}.mtgdb-deck-import{padding:10px 12px}.mtgdb-deck-import textarea{max-height:28vh}}
