.scge-gallery { max-width:100%; color:var(--sc-text,#ead6b7); }
.scge-gallery * { box-sizing:border-box; }
.scge-gallery .scge-grid { display:grid;grid-template-columns:repeat(var(--scge-columns,4),minmax(0,1fr));gap:18px; }
.scge-gallery .scge-title { display:block;color:var(--sc-gold,#f0c979);font:inherit;font-size:18px;line-height:1.4;padding:8px;overflow-wrap:anywhere; }
.scge-gallery .scge-image { min-width:0;width:100%;padding:0;border:0;background:transparent;cursor:pointer;box-shadow:none; }
.scge-gallery .scge-image img { display:block;width:100%;height:240px;object-fit:contain; }
.scge-gallery .scge-dialog { color:var(--sc-text,#ead6b7);background:var(--sc-bg,#100b08);border:1px solid var(--sc-line,#6d482f);border-radius:12px;padding:20px;width:min(880px,calc(100% - 24px));max-height:90dvh;overflow:auto; }
.scge-dialog::backdrop { background:rgba(0,0,0,.8); }
.scge-gallery .scge-detail img { display:block;max-width:100%;width:auto;height:auto;max-height:60dvh;object-fit:contain;margin:16px auto; }
.scge-gallery .scge-detail h2 { color:var(--sc-gold,#f0c979);font-size:clamp(24px,4vw,36px); }
.scge-gallery .scge-text { white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;line-height:1.65; }
.scge-gallery .scge-caption { margin-top:20px; }
.scge-gallery .scge-close { font:inherit;color:var(--sc-gold,#f0c979);background:transparent;border:1px solid var(--sc-line,#6d482f);border-radius:8px;min-height:44px;padding:8px 16px;cursor:pointer; }
.scge-gallery :focus-visible { outline:2px solid var(--sc-gold,#f0c979);outline-offset:3px; }
.scge-flips .scge-card { min-width:0;perspective:1000px; }
.scge-flips .scge-turn { position:relative;width:100%;height:240px;transform-style:preserve-3d;transition:transform .65s ease; }
.scge-flips .is-flipped .scge-turn { transform:rotateY(180deg); }
.scge-flips .scge-face { position:absolute;inset:0;width:100%;height:100%;margin:0;border:1px solid var(--sc-line,#6d482f);border-radius:12px;background:var(--sc-bg,#100b08);color:var(--sc-gold,#f0c979);backface-visibility:hidden;box-shadow:none; }
.scge-gallery.scge-flips .scge-front { display:flex;align-items:center;justify-content:center;padding:0;border:0;background:var(--sc-bg,#100b08);cursor:pointer; }
.scge-gallery.scge-flips .scge-front img { display:block;width:min(80%,160px)!important;height:160px!important;max-height:none;border-radius:0;object-fit:contain; }
.scge-gallery.scge-flips .scge-detail img { width:auto!important;height:auto!important;max-height:min(640px,60dvh)!important; }
.scge-flips .scge-flip-name { display:block;width:100%;min-height:44px;margin:6px 0 0;border:0;background:transparent;cursor:pointer; }
.scge-gallery .scge-tilt { display:block;transition:transform .22s ease,filter .22s ease;transform-style:preserve-3d; }
.scge-flips .scge-back { display:flex;flex-direction:column;gap:12px;padding:18px;transform:rotateY(180deg);color:var(--sc-text,#ead6b7); }
.scge-flips .scge-scroll { flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;text-align:left; }
.scge-flips .scge-scroll h2 { margin:0 0 12px;color:var(--sc-gold,#f0c979);font-size:22px;line-height:1.3; }
.scge-flips .scge-scroll .scge-text { font-size:17px;line-height:1.6; }
.scge-flips .scge-return { flex:none;align-self:center; }
@media(prefers-reduced-motion:reduce){.scge-flips .scge-turn,.scge-gallery .scge-tilt{transition:none;}.scge-gallery .scge-tilt{transform:none!important;filter:none!important;}}
@media(max-width:900px){.scge-gallery .scge-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media(max-width:480px){.scge-gallery .scge-grid{grid-template-columns:minmax(0,1fr);}}

/* The popup uses the existing gallery colors; the cards themselves are unchanged. */
.scge-gallery .scge-dialog { width:min(1120px,calc(100% - 24px));padding:0; }
.scge-dialog .scge-dialog-header { position:sticky;top:0;z-index:1;background:var(--sc-bg,#100b08);padding:16px 20px;border-bottom:1px solid var(--sc-line,#6d482f); }
.scge-dialog .scge-breadcrumb ol { display:flex;align-items:center;flex-wrap:wrap;gap:8px;list-style:none;padding:0;margin:0 0 12px; }
.scge-breadcrumb li+li::before { content:'›';margin-right:8px; }
.scge-breadcrumb .scge-gallery-return { font:inherit;color:var(--sc-gold,#f0c979);background:transparent;border:0;text-decoration:underline;cursor:pointer;min-height:44px;padding:0; }
.scge-dialog .scge-current-title { overflow-wrap:anywhere;min-width:0; }
.scge-dialog .scge-dialog-controls { display:flex;align-items:center;flex-wrap:wrap;gap:8px; }
.scge-dialog .scge-dialog-close { margin-left:auto; }
.scge-dialog .scge-position { font:inherit;font-variant-numeric:tabular-nums;white-space:nowrap; }
.scge-dialog .scge-close:disabled { opacity:.4;cursor:default; }
.scge-dialog .scge-detail { display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:start;gap:24px;padding:24px; }
.scge-dialog .scge-description { min-width:0; }
.scge-dialog .scge-description h2 { margin:0 0 16px; }
.scge-dialog .scge-enlarge { display:block;width:100%;min-width:0;border:0;padding:0;background:transparent;cursor:zoom-in; }
.scge-gallery .scge-dialog .scge-enlarge img { width:auto!important;height:auto!important;max-width:100%;max-height:65dvh!important;object-fit:contain;margin:0 auto; }
.scge-dialog.scge-maximized { width:calc(100% - 24px);height:calc(100dvh - 24px);max-height:calc(100dvh - 24px);overflow:hidden; }
.scge-dialog.scge-maximized[open] { display:flex;flex-direction:column; }
.scge-maximized .scge-dialog-header { flex:none; }
.scge-maximized .scge-detail { display:block;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain; }
.scge-maximized .scge-description { display:none; }
.scge-maximized .scge-enlarge { width:max-content;min-width:100%;cursor:zoom-out; }
.scge-gallery .scge-dialog.scge-maximized .scge-enlarge img { max-width:none;max-height:none!important; }
.scge-dialog [hidden] { display:none!important; }
@media(max-width:700px){
    .scge-dialog .scge-detail { grid-template-columns:minmax(0,1fr);gap:20px;padding:16px; }
    .scge-dialog .scge-dialog-header { padding:12px; }
    .scge-dialog .scge-dialog-controls { gap:6px; }
    .scge-dialog .scge-close { padding:6px 10px; }
}
