/* Legends: compact, full-photo masonry. Intrinsic ratios preserve every composition. */
#club .legends.legends-layout-grid {
  display: block;
  column-count: 5;
  column-gap: 14px;
}

#club .legends-layout-grid .legends-grid-card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: auto !important;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 14px;
  padding: 6px;
  overflow: hidden;
  border: 1px solid #e7e2db;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 14px #3b28120b;
  isolation: isolate;
  cursor: zoom-in;
  transition: box-shadow 180ms ease, border-color 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

/* Intrinsic width/height attributes reserve the correct ratio before loading.
   No fixed image box, crop, hover zoom, or stretched portrait. */
#club .legends-grid-card picture,
#club .legends-grid-card img {
  position: static;
  inset: auto;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
}

#club .legends-grid-card picture { border-radius: 5px; overflow: hidden; }
#club .legends-grid-card img {
  object-fit: contain !important;
  filter: none;
  transform: none;
}

.legends-expand {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #ffffff70;
  border-radius: 50%;
  background: #1b1b1b8c;
  color: #fff;
  box-shadow: 0 2px 12px #0002;
  transition: background 180ms ease, transform 180ms ease;
}

#club .legends-grid-card:focus-visible { outline: 3px solid #a53630; outline-offset: 5px; }
#club .legends-grid-card:focus-visible .legends-expand { background: #982f2a; }

@media (hover: hover) and (pointer: fine) {
  #club .legends-grid-card:hover { border-color: #c5a79e; box-shadow: 0 6px 22px #3b281218; }
  #club .legends-grid-card:hover .legends-expand { background: #982f2a; transform: scale(1.08); }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #club .legends.legends-layout-grid { column-count: 3; }
}

html.legends-dialog-open { overflow: hidden; }

#legends-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 28px;
  overflow: auto;
  overscroll-behavior: contain;
  background: transparent;
  color: #fff;
}

#legends-lightbox:not([open]) { display: none; }
#legends-lightbox[open] { display: grid; place-items: center; }
#legends-lightbox::backdrop { background: #111114e8; backdrop-filter: blur(7px); }

.legends-viewer {
  position: relative;
  width: min(1100px, 100%);
  min-width: 0;
  margin: auto;
  border-radius: 14px;
  background: #19191b;
  box-shadow: 0 24px 100px #0005;
  transform-origin: center;
}

.legends-viewer-image {
  display: grid;
  place-items: center;
  height: min(73vh, 760px);
  height: min(73dvh, 760px);
  overflow: hidden;
  border-radius: 14px 14px 0 0;
  background: #111113;
}

.legends-viewer-image picture,
.legends-viewer-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.legends-viewer-image img { object-fit: contain; filter: none; }

.legends-viewer-caption {
  margin: 0;
  padding: 20px 24px;
  color: #f4f1ed;
  font: 400 15px/1.5 Arial, Helvetica, sans-serif;
  text-wrap: pretty;
}

.legends-viewer-close {
  position: absolute;
  z-index: 1;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #ffffff70;
  border-radius: 50%;
  padding: 0;
  background: #1b1b1bd9;
  color: #fff;
  cursor: pointer;
  transition: background 160ms ease;
}

.legends-viewer-close:hover { background: #a53630; }
.legends-viewer-close:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

.legends-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 639px) {
  #club .legends.legends-layout-grid { column-count: 2; column-gap: 10px; }
  #club .legends-layout-grid .legends-grid-card { margin-bottom: 10px; padding: 4px; }
  .legends-expand { right: 10px; bottom: 10px; width: 28px; height: 28px; }
  #legends-lightbox { padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .legends-viewer-image,
  .legends-viewer-image picture { height: auto; }
  .legends-viewer-image img { height: auto; max-height: 67vh; max-height: 67dvh; }
  .legends-viewer-caption { padding: 18px; font-size: 14px; }
  .legends-viewer-close { top: 10px; right: 10px; }
}

@media (max-height: 500px) and (min-width: 640px) {
  #legends-lightbox { padding: 12px; }
  .legends-viewer-image { height: 68vh; height: 68dvh; }
  .legends-viewer-caption { padding: 12px 20px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  #club .legends-grid-card,
  .legends-expand,
  .legends-viewer-close { transition: none; }
  #club .legends-grid-card:hover .legends-expand { transform: none; }
}

/* Mobile-first fixed bulletin board. Only the full-photo anchors are positioned;
   intrinsic image proportions and the existing accessible viewer stay intact. */
#club .legends.legends-layout-grid.legends-bulletin {
 position:relative; display:block; column-count:auto; width:100%; overflow:hidden;
 border-radius:14px; background:#f1f0ed; isolation:isolate;
}
#club .legends-bulletin .legends-grid-card {
 position:absolute; left:0; top:0; width:auto; height:auto; margin:0; padding:4px;
 border-radius:7px; transform-origin:50% 50%; z-index:1; background:#fffefa;
 box-shadow:0 5px 12px #2619141c,0 9px 18px #26191412; touch-action:auto;
}
#club .legends-bulletin .legends-grid-card picture { border-radius:3px; }
#club .legends-bulletin .legends-grid-card img { -webkit-user-drag:none; }
#club .legends-bulletin .legends-grid-card:focus-visible { z-index:2; outline-offset:2px; }
#club .legends-bulletin .legends-expand { width:24px; height:24px; right:8px; bottom:8px; }
#club .legends-board-title {
 position:absolute; left:50%; transform:translate(-50%,-50%); top:50%; z-index:0;
 width:calc(100% - 24px); margin:0; font:400 29px/1.1 Arial,Helvetica,sans-serif;
 letter-spacing:-.045em; text-align:center; color:#8d8882; pointer-events:none;
}
#club .legends-title-strong { font-weight:400; color:#38332f; }
@media(min-width:640px){
 #club .legends.legends-layout-grid.legends-bulletin { border-radius:20px; }
 #club .legends-bulletin .legends-grid-card { padding:6px; border-radius:9px; }
 #club .legends-board-title { font-size:clamp(32px,3.3vw,46px); }
 #club .legends-bulletin .legends-expand { width:30px; height:30px; right:11px; bottom:11px; }
}

/* Freeze each original frame's footprint while new full photographs flip inside. */
#club .legends-grid-card.legends-rotating-card picture { aspect-ratio:var(--legend-frame-ratio); width:100%; height:auto; background:#fffefa; }
#club .legends-grid-card.legends-rotating-card img { width:100%; height:100%; object-fit:contain!important; }
.legends-photo-controls { display:flex; justify-content:center; margin:10px 0 0; }
.legends-photo-controls button { display:inline-grid; place-items:center; width:44px; height:44px; min-height:44px; padding:0; border:0; border-radius:50%; background:transparent; color:#51483f; cursor:pointer; }
.legends-photo-toggle svg { display:block; width:40px; height:40px; pointer-events:none; }
.legends-photo-controls button:focus-visible { outline:3px solid #a53630; outline-offset:3px; }

/* Permanent Wenger highlight: accent only, no footprint or layout change. */
#club .legends-grid-card[data-legend-feature="wenger"] { border-color:#a53630; box-shadow:0 0 0 1px #a5363033,0 7px 18px #26191422; }
