#collection-open {
  width: 100%;
  margin: 1px 0 8px;
  padding: 8px 11px;
  border-color: #aee59370;
  background: #20342e;
  color: #e6fbdc;
  text-align: left;
  font-size: 13px;
}

#collection-open::after { content: "↗"; float: right; color: var(--green); }
#collection-open[data-selected="true"] { border-color: var(--green); }
.avatar-card-art {
  display: block;
  width: min(76px, 100%);
  height: auto;
  aspect-ratio: 7 / 9;
  border-radius: 6px;
  background: radial-gradient(ellipse at 51% 76%, #395848, #192a30 76%);
}
#menu #avatars button {
  align-content: start;
  padding: 4px 3px 6px;
  gap: 4px;
}
#menu #avatars .avatar-card-art { width: min(53px, 100%); }
#menu #avatars button[aria-pressed="true"] .avatar-card-art,
#collection-cards button[aria-pressed="true"] .avatar-card-art {
  background: radial-gradient(ellipse at 52% 72%, #526c45, #203834 76%);
}
#avatar-preview {
  background:
    radial-gradient(ellipse at 50% 87%, #91bd7740, transparent 50%),
    radial-gradient(ellipse at 50% 62%, #345852, #11252d 73%, #101c22);
}
body:has(#avatar-collection[open]) #avatar-preview { visibility: hidden; }
.duel-person:has(.avatar-card-art) { grid-template-columns: 44px minmax(0,1fr); }
.duel-person .avatar-card-art { width: 44px; }
#avatar-name, #collection-selected { overflow-wrap: anywhere; }

#avatar-collection {
  width: min(920px, calc(100% - 32px));
  max-width: none;
  max-height: min(90svh, 820px);
  padding: clamp(12px, 3vw, 26px);
  background: #101b21;
}
#avatar-collection::backdrop { background: #050c13dc; }
.collection-layout { display: grid; grid-template-columns: minmax(200px, .74fr) minmax(0, 1.26fr); gap: 14px; }
.collection-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }
.collection-header h2 { font-size: clamp(25px, 5vw, 43px); margin: 5px 0 0; letter-spacing: -.054em; }
#avatar-collection .collection-header form { margin: 0; }
.collection-header button { min-width: 44px; min-height: 44px; padding: 4px; font-size: 22px; }
.collection-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 330px;
  height: min(52svh, 465px);
  border-radius: 12px;
  border: 1px solid #83ac9852;
  background: radial-gradient(ellipse at 50% 74%, #2b4a40, #10212a 68%, #0e1921);
  overflow: hidden;
}
#collection-view { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; touch-action: pan-y; cursor: grab; }
#collection-view:active { cursor: grabbing; }
.collection-rotate {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 7px;
  padding: 6px;
  border-top: 1px solid #83ac9852;
  background: #111d23;
  text-align: center;
}
.collection-rotate button { width: 44px; height: 44px; padding: 4px; font-size: 20px; }
.collection-rotate b { font-size: clamp(12px, 2.3vw, 16px); }
.collection-browse { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-width: 0; height: min(52svh, 465px); min-height: 330px; }
#collection-search {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #82a79265;
  border-radius: 7px;
  background: #0c171d;
  color: var(--white);
  font: inherit;
}
#collection-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(96px, 28%), 1fr));
  grid-auto-rows: minmax(140px, max-content);
  align-content: start;
  align-items: stretch;
  gap: 6px;
  overflow: auto;
  scrollbar-width: thin;
  padding: 2px 4px 5px 2px;
}
#collection-cards button {
  display: grid;
  align-content: start;
  justify-items: center;
  min-width: 0;
  min-height: 72px;
  padding: 5px;
  border-color: #9fbbad43;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.19;
  gap: 5px;
}
#collection-cards button[aria-pressed="true"] { border-color: var(--green); background: #294337; }
#collection-cards .avatar-card-art { justify-self: center; width: min(72px, 100%); }
#collection-cards .avatar-card-name { display: block; min-height: 2.4em; width: 100%; }
#avatar-collection .collection-empty { margin: 6px 0; grid-column: 1 / -1; font-size: 13px; }
.collection-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}
.collection-wardrobe {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #d9ebd8;
  font-size: 13px;
}
.collection-wardrobe select { min-width: 0; min-height: 44px; }
.collection-footer button { min-height: 44px; }
#avatar-collection :is(button, input, select):focus-visible, #collection-open:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

@media (max-width: 680px) {
  #collection-open { min-height: 44px; }
  #avatar-collection { width: calc(100% - 18px); max-height: 94svh; }
  .collection-layout { grid-template-columns: 1fr; gap: 8px; }
  .collection-header { margin-bottom: 8px; }
  .collection-stage { height: clamp(161px, 32svh, 253px); min-height: 0; }
  .collection-rotate { padding: 3px 5px; }
  .collection-browse { height: clamp(116px, 32svh, 270px); min-height: 0; }
  #collection-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(124px, max-content); }
  #collection-cards .avatar-card-art { width: min(63px, 100%); }
  .collection-footer { margin-top: 8px; }
  .collection-wardrobe { width: 100%; }
  .collection-wardrobe select { flex: 1; }
  .collection-footer button { width: 100%; }
}
@media (max-width: 355px) {
  #collection-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
