.sparrow-collection-page {
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff4ec;
  color: var(--ink, #27313d);
}

.sparrow-collection-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(34px + env(safe-area-inset-bottom));
}

.sparrow-collection-header {
  display: grid;
  grid-template-columns: 40px 1fr 62px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 10px;
}

.sparrow-collection-header h1 {
  margin: 0;
  color: #26323d;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}

.sparrow-collection-back,
.sparrow-collection-wardrobe-link {
  color: var(--accent, #d85a30);
  text-decoration: none;
}

.sparrow-collection-back {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
}

.sparrow-collection-back:hover,
.sparrow-collection-back:focus-visible {
  background: rgba(216, 90, 48, 0.1);
}

.sparrow-collection-back svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.sparrow-collection-wardrobe-link {
  justify-self: end;
  padding: 7px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.sparrow-collection-wardrobe-link:hover,
.sparrow-collection-wardrobe-link:focus-visible {
  background: rgba(216, 90, 48, 0.1);
}

.sparrow-collection-progress-card {
  padding: 16px 16px 13px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(82, 124, 112, 0.13);
  border-radius: 16px;
  box-shadow: 0 9px 24px rgba(76, 116, 104, 0.08);
}

.sparrow-collection-progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #596a69;
  font-size: 14px;
}

.sparrow-collection-progress-heading strong {
  color: var(--accent, #d85a30);
  font-size: 19px;
  letter-spacing: 0.04em;
}

.sparrow-collection-progress-track {
  height: 8px;
  margin-top: 11px;
  overflow: hidden;
  background: #e4ebe8;
  border-radius: 999px;
}

.sparrow-collection-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent, #d85a30);
  border-radius: inherit;
  transition: width 220ms ease;
}

.sparrow-collection-progress-card p {
  margin: 9px 0 0;
  color: #83918e;
  font-size: 12px;
}

.sparrow-collection-main-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 20px;
  border-bottom: 1px solid #d5e1dd;
}

.sparrow-collection-main-tabs button {
  position: relative;
  min-height: 44px;
  padding: 0 8px;
  color: #81908d;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.sparrow-collection-main-tabs button.is-active { color: var(--accent, #d85a30); }

.sparrow-collection-main-tabs button.has-new-collection { color: #b24c23; }

.sparrow-collection-tab-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 5px;
  vertical-align: 2px;
  background: var(--accent, #d85a30);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 2px 5px rgba(111, 56, 25, 0.35);
}

.sparrow-collection-main-tabs button.is-active::after {
  position: absolute;
  right: 14%;
  bottom: -1px;
  left: 14%;
  height: 3px;
  background: var(--accent, #d85a30);
  border-radius: 3px 3px 0 0;
  content: "";
}

.sparrow-collection-main-tabs button:disabled {
  color: #b7c1be;
  cursor: not-allowed;
}

.sparrow-collection-species-panel { padding-top: 15px; }

.sparrow-collection-character-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 3px 8px;
  scrollbar-width: none;
}

.sparrow-collection-character-tabs::-webkit-scrollbar { display: none; }

.sparrow-collection-character-tabs button {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 34px;
  padding: 0 12px;
  color: #687d78;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #d7e4df;
  border-radius: 999px;
  cursor: pointer;
}

.sparrow-collection-character-tabs button.has-new-collection {
  color: #b24c23;
}

.sparrow-collection-character-tab-badge {
  position: absolute;
  top: -4px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: var(--accent, #d85a30);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 2px 5px rgba(111, 56, 25, 0.35);
  pointer-events: none;
}

.sparrow-collection-character-tabs button.is-active {
  color: #fff;
  background: var(--accent, #d85a30);
  border-color: var(--accent, #d85a30);
  box-shadow: 0 5px 13px rgba(216, 90, 48, 0.18);
}

.sparrow-collection-character-tabs button:focus-visible,
.sparrow-collection-rarity-filters label:focus-within,
.sparrow-collection-card:focus-visible {
  outline: 3px solid rgba(216, 90, 48, 0.3);
  outline-offset: 2px;
}

.sparrow-collection-rarity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 6px 0 12px;
  padding: 0;
  border: 0;
}

.sparrow-collection-rarity-filters legend {
  width: 100%;
  margin-bottom: 1px;
  color: #82928d;
  font-size: 12px;
}

.sparrow-collection-rarity-filters label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #667773;
  font-size: 12px;
  cursor: pointer;
}

.sparrow-collection-rarity-filters input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent, #d85a30);
}

.sparrow-collection-rarity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sparrow-collection-rarity-dot.is-blue { background: #5d9ee9; }
.sparrow-collection-rarity-dot.is-green { background: #62b36b; }
.sparrow-collection-rarity-dot.is-purple { background: #9573c9; }
.sparrow-collection-rarity-dot.is-gold { background: #df9d2e; }

.sparrow-collection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.sparrow-collection-card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 118px;
  padding: 7px 6px 8px;
  color: #5e6c69;
  text-align: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1.5px solid #cbd3d1;
  border-radius: 13px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.sparrow-collection-card:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 8px 18px rgba(70, 96, 89, 0.11);
}

.sparrow-collection-card.is-selected {
  border-color: var(--accent, #d85a30);
  box-shadow: 0 0 0 2px rgba(216, 90, 48, 0.14);
}

.sparrow-collection-card.rarity-blue { border-color: #6fa9ed; }
.sparrow-collection-card.rarity-green { border-color: #62b36b; }
.sparrow-collection-card.rarity-purple { border-color: #9c7bc9; }
.sparrow-collection-card.rarity-gold { border-color: #e0a035; border-style: dashed; }
.sparrow-collection-card.rarity-green.is-selected,
.sparrow-collection-card.rarity-purple.is-selected,
.sparrow-collection-card.rarity-gold.is-selected { border-color: var(--accent, #d85a30); }
.sparrow-collection-card.is-unowned { background: rgba(255, 255, 255, 0.52); }
.sparrow-collection-card.is-unowned .sparrow-collection-card-visual { color: #9daaa6; }

.sparrow-collection-card-visual {
  display: grid;
  min-height: 78px;
  place-items: center;
  color: #c58a27;
}

.sparrow-collection-card-visual .outfit-reward-sparrow,
.sparrow-collection-card-visual .outfit-sparrow-stage,
.sparrow-collection-card-visual .outfit-canvas {
  width: 100%;
  height: 78px;
}

.sparrow-collection-card-visual .outfit-sparrow-stage { min-height: 0; background: transparent; }
.sparrow-collection-card-visual .outfit-canvas { transform: scale(0.98); transform-origin: center; }

.sparrow-collection-card-visual .sparrow-collection-background-image {
  display: block;
  width: 100%;
  height: 78px;
  object-fit: cover;
  object-position: center;
  border-radius: 9px;
}

.sparrow-collection-card-visual .sparrow-collection-egg-image {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.sparrow-collection-egg-fallback {
  font-size: 52px;
  line-height: 1;
}

.sparrow-collection-hidden-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #9ca9a6;
  font-family: Georgia, serif;
  font-size: 23px;
  border: 1px solid #d7dfdc;
  border-radius: 50%;
}

.sparrow-collection-card.rarity-gold .sparrow-collection-hidden-mark { color: #d59320; font-size: 19px; border-color: #e2b560; }

.sparrow-collection-card-label {
  overflow: hidden;
  margin-top: 1px;
  color: #5d6b69;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sparrow-collection-card-index {
  position: absolute;
  top: 7px;
  left: 8px;
  color: #a1adaa;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.sparrow-collection-card-new-badge {
  position: absolute;
  top: 7px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--accent, #d85a30);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 2px 5px rgba(111, 56, 25, 0.35);
}

.sparrow-collection-loading,
.sparrow-collection-empty {
  grid-column: 1 / -1;
  margin: 25px 0;
  color: #82918d;
  font-size: 14px;
  text-align: center;
}

.sparrow-collection-detail {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  width: min(420px, calc(100vw - 32px));
  max-height: min(78vh, 520px);
  gap: 13px;
  align-items: center;
  justify-items: center;
  margin: auto;
  padding: 18px 16px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(36, 58, 53, 0.25);
}

.sparrow-collection-detail:not([open]) {
  display: none;
}

.sparrow-collection-detail[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
}

.sparrow-collection-detail::backdrop {
  background: rgba(28, 47, 43, 0.34);
  backdrop-filter: blur(2px);
}

.sparrow-collection-detail[data-collection-rarity="blue"] {
  background: linear-gradient(145deg, rgba(234, 243, 253, 0.98), rgba(246, 251, 248, 0.98));
}

.sparrow-collection-detail[data-collection-rarity="green"] {
  background: linear-gradient(145deg, rgba(234, 247, 235, 0.98), rgba(246, 251, 248, 0.98));
}

.sparrow-collection-detail[data-collection-rarity="purple"] {
  background: linear-gradient(145deg, rgba(241, 235, 251, 0.98), rgba(246, 251, 248, 0.98));
}

.sparrow-collection-detail[data-collection-rarity="gold"] {
  background: linear-gradient(145deg, rgba(255, 244, 220, 0.98), rgba(246, 251, 248, 0.98));
}

.sparrow-collection-detail-close {
  position: absolute;
  top: 8px;
  right: 9px;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  color: #72827d;
  font-size: 22px;
  line-height: 1;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.sparrow-collection-detail-close:hover,
.sparrow-collection-detail-close:focus-visible {
  color: var(--accent, #d85a30);
  background: #fff0ea;
}

.sparrow-collection-detail-visual {
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  overflow: hidden;
  background: #f4faf7;
  border-radius: 13px;
}

.sparrow-collection-detail-visual.rarity-blue {
  background: linear-gradient(180deg, rgba(93, 158, 233, 0.12), rgba(244, 250, 247, 0.96));
}

.sparrow-collection-detail-visual.rarity-green {
  background: linear-gradient(180deg, rgba(98, 179, 107, 0.12), rgba(244, 250, 247, 0.96));
}

.sparrow-collection-detail-visual.rarity-purple {
  background: linear-gradient(180deg, rgba(149, 115, 201, 0.12), rgba(244, 250, 247, 0.96));
}

.sparrow-collection-detail-visual.rarity-gold {
  background: linear-gradient(180deg, rgba(223, 157, 46, 0.14), rgba(244, 250, 247, 0.96));
}

.sparrow-collection-detail-visual .outfit-reward-sparrow,
.sparrow-collection-detail-visual .outfit-sparrow-stage,
.sparrow-collection-detail-visual .outfit-canvas {
  width: 100%;
  height: 150px;
}

.sparrow-collection-detail-visual .outfit-canvas { transform: scale(0.9); transform-origin: center; }
.sparrow-collection-detail-visual .sparrow-collection-background-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.sparrow-collection-detail-visual .sparrow-collection-egg-image {
  display: block;
  width: 132px;
  height: 132px;
  object-fit: contain;
}
.sparrow-collection-detail-copy {
  position: relative;
  width: 100%;
  min-width: 0;
  padding: 15px 14px 12px;
  background: #f5fbf8;
  border: 1.5px solid #d2e5dd;
  border-radius: 18px;
}

.sparrow-collection-detail-copy::before {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 14px;
  height: 14px;
  background: #f5fbf8;
  border-top: 1.5px solid #d2e5dd;
  border-left: 1.5px solid #d2e5dd;
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.sparrow-collection-detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.sparrow-collection-detail-title-group {
  min-width: 0;
}

.sparrow-collection-detail h2 {
  overflow: hidden;
  margin: 0;
  color: #374641;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sparrow-collection-detail-skin-name {
  margin: 3px 0 0;
  color: #81918c;
  font-size: 12px;
  line-height: 1.35;
}

.sparrow-collection-detail-rarity {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: var(--accent, #d85a30);
  font-size: 11px;
  font-weight: 800;
  background: #fff0ea;
  border-radius: 999px;
}

.sparrow-collection-detail-rarity.rarity-blue {
  color: #3976b7;
  background: #eaf3fd;
}

.sparrow-collection-detail-rarity.rarity-green {
  color: #3f8848;
  background: #eaf7eb;
}

.sparrow-collection-detail-rarity.rarity-purple {
  color: #7652a6;
  background: #f1ebfb;
}

.sparrow-collection-detail-rarity.rarity-gold {
  color: #a87311;
  background: #fff4dc;
}

.sparrow-collection-detail p { margin: 6px 0 0; color: #778783; font-size: 12px; line-height: 1.6; }
.sparrow-collection-detail p + p { margin-top: 1px; }

.sparrow-collection-toast {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 10;
  width: fit-content;
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 10px 14px;
  color: #fff;
  font-size: 13px;
  background: #374641;
  border-radius: 999px;
  box-shadow: 0 9px 24px rgba(32, 47, 43, 0.2);
}

@media (max-width: 410px) {
  .sparrow-collection-shell { padding-right: 13px; padding-left: 13px; }
  .sparrow-collection-grid { gap: 7px; }
  .sparrow-collection-card { min-height: 110px; }
  .sparrow-collection-card-visual,
  .sparrow-collection-card-visual .outfit-reward-sparrow,
  .sparrow-collection-card-visual .outfit-sparrow-stage,
  .sparrow-collection-card-visual .outfit-canvas { height: 71px; min-height: 71px; }
}
