.level-library-page {
  --level-ink: #18233a;
  --level-panel: #f6f8fd;
}

.level-library-hero {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 88% 12%, rgba(37, 99, 235, .16), transparent 27%), linear-gradient(135deg, #f8fbff, #f7f4ff);
}

.level-library-hero::after {
  content: "";
  position: absolute;
  right: 7%;
  bottom: -72px;
  width: 190px;
  height: 190px;
  border: 26px solid rgba(124, 58, 237, .08);
  border-radius: 50%;
  pointer-events: none;
}

.level-library-hero > * {
  position: relative;
  z-index: 1;
}

.level-library-hero .eyebrow {
  margin: 28px 0 5px;
  color: #6d28d9;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.level-hero-actions,
.level-card-actions,
.level-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.level-hero-actions {
  margin-top: 22px;
}

.level-explorer .section-heading {
  align-items: end;
}

.level-explorer .section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.level-explorer .section-heading > strong {
  color: #475569;
  white-space: nowrap;
}

.level-type-tabs {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.level-type-tabs button,
.level-reset {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
}

.level-type-tabs button:hover,
.level-type-tabs button:focus-visible,
.level-type-tabs button.is-active {
  background: #eaf2ff;
  color: #174ea6;
}

.level-filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--level-panel);
}

.level-filter-bar label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.level-filter-bar label span {
  color: #526079;
  font-size: .78rem;
  font-weight: 850;
}

.level-filter-bar select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd7e6;
  border-radius: 10px;
  padding: 0 34px 0 11px;
  background: #fff;
  color: var(--level-ink);
  font: inherit;
}

.level-reset {
  border: 1px solid #cfd7e6;
  background: #fff;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.level-card {
  display: grid;
  grid-template-columns: 134px minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 17px;
  background: #fff;
  box-shadow: 0 9px 28px rgba(37, 50, 78, .07);
}

.level-card[hidden] {
  display: none;
}

.level-card.is-complete {
  border-color: #9ed7b1;
  box-shadow: 0 9px 28px rgba(22, 163, 74, .09);
}

.level-card-preview {
  display: grid;
  align-content: center;
  justify-items: center;
  align-self: start;
  min-height: 158px;
  border-radius: 14px;
  background: linear-gradient(145deg, #ecf5ff, #e3ebfb);
  color: #1e3a5f;
}

.level-card-preview.is-ball {
  background: linear-gradient(145deg, #fff5e7, #ffe9bf);
  color: #7c3f00;
}

.level-card-preview.is-stack {
  background: linear-gradient(145deg, #f3edff, #e7dcff);
  color: #5827a4;
}

.level-preview-shapes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 84px;
  margin-bottom: 12px;
}

.level-preview-shapes i {
  width: 18px;
  height: 31px;
  border: 2px solid rgba(22, 34, 58, .24);
  border-radius: 5px 5px 8px 8px;
  background: linear-gradient(to top, var(--level-color) 0 62%, rgba(255, 255, 255, .7) 62%);
}

.is-ball .level-preview-shapes i {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--level-color);
}

.is-stack .level-preview-shapes i {
  width: 25px;
  height: 25px;
  border-radius: 6px;
  background: var(--level-color);
}

.level-card-preview strong {
  font-size: 1.7rem;
  line-height: 1;
}

.level-card-preview small {
  margin-top: 4px;
  font-weight: 750;
}

.level-card-body {
  min-width: 0;
}

.level-card-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.level-type-label {
  color: #64748b;
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.level-card h2 {
  margin: 3px 0 0;
  font-size: 1.16rem;
}

.level-difficulty {
  flex: none;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .72rem;
  font-weight: 900;
}

.level-difficulty.is-easy { background: #dcfce7; color: #166534; }
.level-difficulty.is-medium { background: #fef3c7; color: #92400e; }
.level-difficulty.is-hard { background: #fee2e2; color: #991b1b; }

.level-card-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 12px;
}

.level-card-meta div {
  min-width: 0;
  border-radius: 9px;
  padding: 8px;
  background: #f7f9fc;
}

.level-card-meta dt {
  color: #718096;
  font-size: .68rem;
}

.level-card-meta dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  color: #26344d;
  font-size: .8rem;
  font-weight: 850;
}

.level-card-badges span {
  border-radius: 999px;
  padding: 5px 8px;
  background: #eef2f7;
  color: #556276;
  font-size: .72rem;
  font-weight: 800;
}

.level-card-badges .has-helper { background: #eaf2ff; color: #1d4ed8; }
.level-card-badges .is-verified { background: #f1eaff; color: #6d28d9; }
.level-card-badges .is-complete { background: #dcfce7; color: #166534; }

.level-why {
  margin: 12px 0;
  border-top: 1px solid #edf0f5;
  border-bottom: 1px solid #edf0f5;
  padding: 9px 0;
}

.level-why summary {
  color: #30415f;
  font-size: .82rem;
  font-weight: 850;
  cursor: pointer;
}

.level-why p {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.55;
}

.level-card-actions small {
  flex: 1 1 150px;
  color: #718096;
  line-height: 1.35;
}

.level-empty {
  border: 1px dashed #bdc8d9;
  border-radius: 18px;
  padding: 42px 20px;
  text-align: center;
  background: #fafcff;
}

.level-empty h2 {
  margin-top: 0;
}

.level-library-note {
  border-top: 1px solid var(--line);
}

@media (max-width: 960px) {
  .level-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-reset { min-height: 44px; }
  .level-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .level-filter-bar { grid-template-columns: 1fr; padding: 13px; }
  .level-card { grid-template-columns: 82px minmax(0, 1fr); gap: 12px; padding: 13px; }
  .level-card-preview { min-height: 118px; }
  .level-preview-shapes { width: 66px; gap: 4px; }
  .level-preview-shapes i { width: 13px; height: 24px; }
  .is-ball .level-preview-shapes i { width: 16px; height: 16px; }
  .is-stack .level-preview-shapes i { width: 19px; height: 19px; }
  .level-card-preview strong { font-size: 1.35rem; }
  .level-card-heading { display: block; }
  .level-difficulty { display: inline-block; margin-top: 7px; }
  .level-card-meta { grid-template-columns: 1fr; }
  .level-card-meta div { display: flex; justify-content: space-between; gap: 8px; }
  .level-card-meta dd { margin: 0; text-align: right; }
  .level-card-actions .button { width: 100%; }
}
