/* Knight Games — Trophy Cabinet
   Panel/card WebPs include framed empty slots. Content is positioned INTO those slots.
   Use background-size: 100% 100% (not cover) so slot geometry matches the art. */

.ach-page {
  --ach-squire: #b87333;
  --ach-knight: #c0c7d1;
  --ach-paladin: #d4af37;
  --ach-grandmaster: #9b5de5;
  --ach-ink: #f3efe6;
  --ach-muted: color-mix(in oklch, #f3efe6 70%, transparent);
  --ach-gold: #d4af37;
  --ach-max: 72rem;
  --ach-font-display: "Cinzel", "Palatino Linotype", serif;
  --ach-font-body: "Source Sans 3", "Segoe UI", sans-serif;

  font-family: var(--ach-font-body);
  color: var(--ach-ink);
  margin: -1.5rem 0 0;
  min-height: calc(100dvh - 4rem);
  background-color: #070a10;
  background-image: url("/images/achievements/achievements-hero-bg-mobile.webp");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

@media (min-width: 768px) {
  .ach-page {
    background-image: url("/images/achievements/achievements-hero-bg-desktop.webp");
    background-attachment: fixed;
  }
}

.ach-page__inner {
  width: min(100% - 1.25rem, var(--ach-max));
  margin: 0 auto;
  padding: 1.25rem 0 5.75rem;
}

@media (min-width: 1100px) {
  .ach-page { --ach-max: 80rem; }
}

@media (min-width: 1600px) {
  .ach-page { --ach-max: 92rem; }
  .ach-page__inner { padding: 1.75rem 0 3.5rem; }
}

@media (min-width: 2200px) {
  .ach-page { --ach-max: 125rem; }
}

.ach-progress {
  height: 0.55rem;
  border-radius: 999px;
  background: color-mix(in oklch, black 55%, transparent);
  border: 1px solid color-mix(in oklch, var(--ach-gold) 35%, transparent);
  overflow: hidden;
}

.ach-progress--lg { height: 0.72rem; flex: 1; min-width: 0; }

.ach-progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b87333, #d4af37 55%, #f0d78c);
}

.ach-icon { color: var(--ach-gold); flex-shrink: 0; }

.ach-link-btn {
  background: none;
  border: none;
  color: #f0d78c;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.35rem 0.25rem;
  min-height: 44px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.ach-link-btn:hover,
.ach-link-btn:focus-visible {
  color: #fff;
  text-decoration: underline;
  outline: none;
}

.ach-empty {
  margin: 0;
  color: var(--ach-muted);
  font-size: 0.92rem;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.ach-empty--grid { text-align: center; padding: 1.5rem; }
.ach-empty--panel { padding: 1rem 0.5rem; align-self: center; }
.ach-empty--slot { padding: 0.5rem; font-size: 0.85rem; }

.ach-badge-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 1.6rem;
  color: var(--ach-gold);
}

.ach-badge-fallback--secret { font-size: 1.8rem; font-weight: 700; opacity: 0.75; }
.ach-badge-fallback.is-hidden { display: none; }

/* ========== Profile (2508×627 — avatar circle left, 4 tier slots right) ========== */
/* Locked to the art's 4:1 ratio so the baked medallion stays at fixed percentages. */
.ach-profile {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(0.65rem, 1.8vw, 1.5rem);
  align-items: center;
  aspect-ratio: 2508 / 627;
  width: 100%;
  /* The art has transparent bands above (~13%) and below (~21%) the gold frame. */
  margin: -2% 0 calc(1rem - 4%);
  padding: 4% 42% 6% 15.5%;
  border: none;
  border-radius: 0;
  background: url("/images/achievements/achievements-profile-panel-bg.webp") center / 100% 100% no-repeat;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

/* Medallion interior in the art: center (223, 293), diameter ~266 of 2508×627. */
.ach-profile__avatar-slot {
  position: absolute;
  left: 8.89%;
  top: 46.7%;
  width: 10.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  overflow: hidden;
  background: #0a0d14;
}

.ach-profile__avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.28);
  transform-origin: center;
}

.ach-profile__avatar--fallback {
  display: grid;
  place-items: center;
  color: #f0d78c;
  transform: none;
}

.ach-profile__text {
  min-width: 0;
  padding-right: 0.5rem;
}

.ach-profile__name {
  font-family: var(--ach-font-display);
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
}

.ach-profile__points,
.ach-profile__count {
  margin: 0.2rem 0 0;
  font-size: clamp(0.82rem, 1.2vw, 0.98rem);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.ach-profile__points { color: #f0d78c; font-weight: 700; }
.ach-profile__count { color: var(--ach-muted); }

.ach-profile__progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.55rem;
  max-width: 28rem;
}

.ach-profile__pct {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #f0d78c;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Baked tier slots in the art: x 1494–2410, y 155–445 of 2508×627. */
.ach-tier-summary {
  position: absolute;
  left: 59.6%;
  width: 36.5%;
  top: 24.7%;
  height: 46.3%;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 3.2%;
}

.ach-tier-summary__item {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-items: center;
  justify-items: center;
  gap: 0.05rem;
  text-align: center;
  background: transparent;
  border: none;
  padding: 0.15rem 0.1rem 0.2rem;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.ach-tier-summary__shield {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.ach-tier-summary__shield img {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}

.ach-tier-summary__label {
  font-size: clamp(0.52rem, 0.8vw, 0.68rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ach-muted);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.ach-tier-summary__count {
  font-size: clamp(0.9rem, 1.45vw, 1.2rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.ach-tier--squire,
.ach-tier--squire .ach-tier-summary__shield,
.ach-tier--squire .ach-tier-summary__count { color: var(--ach-squire); }
.ach-tier--knight,
.ach-tier--knight .ach-tier-summary__shield,
.ach-tier--knight .ach-tier-summary__count { color: var(--ach-knight); }
.ach-tier--paladin,
.ach-tier--paladin .ach-tier-summary__shield,
.ach-tier--paladin .ach-tier-summary__count { color: var(--ach-paladin); }
.ach-tier--grandmaster,
.ach-tier--grandmaster .ach-tier-summary__shield,
.ach-tier--grandmaster .ach-tier-summary__count { color: var(--ach-grandmaster); }

/* Portrait panel is 1044×1507. Inner avatar hole center (306, 350), diameter ~300.
   Tier wells at y=1320: x 43–262, 289–502, 535–753, 783–1001; vertical y 1045–1390. */
@media (max-width: 899px) {
  .ach-profile {
    display: block;
    aspect-ratio: 1044 / 1507;
    margin: 0 0 0.85rem;
    min-height: 0;
    padding: 0;
    background-image: url("/images/achievements/achievements-profile-panel-bg-mobile.webp");
    background-size: 100% 100%;
    background-position: center;
    overflow: hidden;
    border-radius: 0;
  }

  .ach-profile__avatar-slot {
    left: 29.3%;
    top: 23.2%;
    width: 26.5%;
    box-shadow: none;
  }

  .ach-profile__avatar {
    transform: none;
  }

  .ach-profile__text {
    position: absolute;
    left: 52%;
    right: 5.5%;
    top: 13.5%;
    padding-right: 0;
  }

  .ach-profile__name { font-size: clamp(0.95rem, 4.2vw, 1.2rem); }

  .ach-profile__points,
  .ach-profile__count {
    font-size: clamp(0.68rem, 2.8vw, 0.82rem);
    margin-top: 0.15rem;
  }

  .ach-profile__progress-wrap {
    flex-wrap: wrap;
    margin-top: 0.35rem;
    max-width: none;
    gap: 0.3rem 0.45rem;
  }

  .ach-profile__pct { font-size: 0.68rem; }

  .ach-tier-summary {
    left: 4.12%;
    top: 69.34%;
    width: 91.76%;
    height: 22.89%;
    column-gap: 3.1%;
  }

  .ach-tier-summary__item {
    padding: 6% 7% 7%;
    background: transparent;
  }

  .ach-tier-summary__label { font-size: clamp(0.48rem, 2.1vw, 0.62rem); }
  .ach-tier-summary__count { font-size: clamp(0.78rem, 3.2vw, 1rem); }
}

/* ========== Mid panels ==========
   Source images are concept composites with baked slots. They are intentionally
   subdued and zoomed here; live CSS owns all borders and layout geometry. */
.ach-mid {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

@media (min-width: 900px) {
  .ach-mid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(13rem, auto);
  }
}

@media (max-width: 899px) {
  .ach-panel--nearly { order: 1; }
  .ach-panel--recent { order: 2; }
  .ach-panel--stats { order: 3; }
}

.ach-panel {
  --ach-panel-art: none;
  position: relative;
  display: grid;
  min-width: 0;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 42%, transparent);
  border-radius: 0.8rem;
  background:
    radial-gradient(circle at 50% 0%, rgba(54, 72, 104, 0.24), transparent 55%),
    linear-gradient(165deg, rgba(14, 20, 32, 0.97), rgba(6, 9, 16, 0.98));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  overflow: hidden;
  isolation: isolate;
}

.ach-panel::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: -2;
  background-image: var(--ach-panel-art);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.16;
  filter: saturate(0.7) brightness(0.65);
}

.ach-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.08), transparent 12%, transparent 88%, rgba(212, 175, 55, 0.08)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 35%);
}

.ach-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  z-index: 1;
  min-height: 2.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid color-mix(in oklch, var(--ach-gold) 26%, transparent);
}

.ach-panel__title {
  font-family: var(--ach-font-display);
  font-size: clamp(0.95rem, 1.3vw, 1.12rem);
  margin: 0;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

.ach-panel__title--centered {
  text-align: center;
  justify-self: center;
}

/* Nearly Earned — 1448×1086, left medallion + content + right chevron slot */
.ach-panel--nearly {
  --ach-panel-art: url("/images/achievements/achievements-nearly-earned-panel-bg.webp");
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  grid-template-rows: auto 1fr;
  padding: 0.7rem;
  z-index: 1;
}

.ach-nearly {
  display: grid;
  grid-template-columns: minmax(5.25rem, 31%) minmax(0, 1fr) 1.5rem;
  gap: 0.7rem;
  align-items: center;
  width: 100%;
  min-height: 0;
  text-align: left;
  background: transparent;
  border: none;
  margin-top: 0.65rem;
  padding: 0.65rem;
  color: inherit;
  cursor: pointer;
  border: 1px solid color-mix(in oklch, var(--ach-grandmaster) 65%, transparent);
  border-radius: 0.65rem;
  background:
    radial-gradient(circle at 10% 50%, rgba(155, 93, 229, 0.18), transparent 35%),
    rgba(3, 6, 12, 0.48);
  box-shadow:
    inset 0 0 18px rgba(155, 93, 229, 0.09),
    0 0 12px rgba(155, 93, 229, 0.1);
}

.ach-nearly:hover .ach-nearly__name,
.ach-nearly:focus-visible .ach-nearly__name {
  color: #fff;
}

.ach-nearly:focus-visible {
  outline: 2px solid color-mix(in oklch, #60a5fa 75%, transparent);
  outline-offset: 3px;
  border-radius: 0.5rem;
}

.ach-nearly__badge {
  width: min(100%, 6.4rem);
  aspect-ratio: 1;
  border-radius: 999px;
  overflow: hidden;
  justify-self: center;
  background: radial-gradient(circle at 40% 35%, #2a2030, #0a0d14 70%);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.28);
}

.ach-nearly__badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ach-nearly__body { min-width: 0; padding-top: 0.2rem; }

.ach-nearly__name {
  margin: 0;
  font-size: clamp(0.95rem, 1.4vw, 1.15rem);
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.ach-nearly__desc {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--ach-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.ach-nearly__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ach-muted);
  margin-bottom: 0.3rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.ach-nearly__chevron {
  font-size: 2rem;
  line-height: 1;
  color: #c4a0ff;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 0 12px color-mix(in oklch, var(--ach-grandmaster) 70%, transparent);
  align-self: center;
}

/* Stats — 1672×941, header strip + 4 equal compartments */
.ach-panel--stats {
  --ach-panel-art: url("/images/achievements/achievements-stats-panel-bg.webp");
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  grid-template-rows: 2.6rem minmax(0, 1fr);
  padding: 0.7rem;
  align-content: stretch;
  z-index: 2;
}

.ach-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  min-height: 0;
  align-items: stretch;
}

.ach-stats__tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  text-align: center;
  padding: 0.55rem 0.2rem;
  background: rgba(3, 6, 12, 0.45);
  border: 1px solid color-mix(in oklch, var(--ach-gold) 22%, transparent);
  border-radius: 0.55rem;
  min-width: 0;
  height: 100%;
}

.ach-stats__icon { color: var(--ach-gold); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.ach-stats__icon--fire { color: #f59e0b; }

.ach-stats__value {
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.ach-stats__value--sm {
  font-size: clamp(0.75rem, 1vw, 0.95rem);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.15rem;
}

.ach-stats__label {
  font-size: clamp(0.52rem, 0.68vw, 0.66rem);
  color: var(--ach-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.ach-stats__ring {
  --pct: 0;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #0c1018 58%, transparent 59%),
    conic-gradient(var(--ach-gold) calc(var(--pct) * 1%), color-mix(in oklch, white 12%, transparent) 0);
  font-size: 0.72rem;
  font-weight: 800;
  color: #f0d78c;
}

/* Recent Unlocks — 1448×1086, header art + 3 list slots */
.ach-panel--recent {
  --ach-panel-art: url("/images/achievements/achievements-recent-unlocks-panel-bg.webp");
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  grid-template-rows: 2.7rem minmax(0, 1fr);
  padding: 0.7rem;
  z-index: 1;
}

.ach-panel__head--recent {
  align-items: flex-start;
  padding-top: 0.1rem;
}

.ach-recent {
  list-style: none;
  margin: 0;
  padding: 0.55rem 0 0;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  min-height: 0;
  overflow: hidden;
}

.ach-recent__slot {
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.ach-recent__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.4rem;
  width: 100%;
  align-items: center;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.35rem;
  padding: 0.28rem 0.4rem;
  color: inherit;
  cursor: pointer;
  min-height: 0;
  height: 100%;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 19%, transparent);
  background: rgba(3, 6, 12, 0.46);
}

.ach-recent__row:hover,
.ach-recent__row:focus-visible {
  background: color-mix(in oklch, white 6%, transparent);
  outline: none;
}

.ach-recent__badge {
  width: clamp(1.9rem, 11%, 2.4rem);
  aspect-ratio: 1;
  border-radius: 0.3rem;
  overflow: hidden;
  background: color-mix(in oklch, black 35%, transparent);
  flex-shrink: 0;
}

.ach-recent__badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ach-recent__text {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.ach-recent__name {
  color: var(--ach-ink);
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.ach-recent__desc {
  font-size: 0.72rem;
  color: var(--ach-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.ach-recent__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: 0.64rem;
  color: var(--ach-muted);
  flex-shrink: 0;
  text-align: right;
}

.ach-recent__pts {
  color: #f0d78c;
  font-weight: 700;
}

@media (max-width: 899px) {
  .ach-panel--nearly,
  .ach-panel--stats,
  .ach-panel--recent {
    aspect-ratio: auto;
    min-height: 13rem;
    height: auto;
    background-size: cover;
  }

  .ach-panel--stats {
    grid-template-rows: auto 1fr;
    padding: 0.7rem;
  }

  .ach-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    min-height: 9rem;
  }

  .ach-nearly {
    grid-template-columns: minmax(4.5rem, 30%) minmax(0, 1fr) 1.75rem;
  }

  .ach-panel--recent {
    grid-template-rows: auto minmax(10rem, 1fr);
    min-height: 15rem;
  }

  .ach-recent {
    gap: 0.45rem;
  }
}

/* ========== Tabs ==========
   The art is atmosphere only; buttons form their own responsive controls. */
.ach-tabs-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  min-height: 3.5rem;
  margin-bottom: 0.75rem;
  padding: 0.45rem;
  background:
    linear-gradient(rgba(7, 11, 19, 0.9), rgba(7, 11, 19, 0.94)),
    url("/images/achievements/achievements-tabs-bar-bg.webp") center / cover no-repeat;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 30%, transparent);
  border-radius: 0.75rem;
}

.ach-tab {
  min-height: 44px;
  min-width: 0;
  padding: 0.4rem 0.35rem;
  border: 1px solid color-mix(in oklch, white 12%, transparent);
  border-radius: 0.55rem;
  background: rgba(2, 5, 10, 0.52);
  color: var(--ach-ink);
  font: inherit;
  font-weight: 700;
  font-size: clamp(0.78rem, 1.05vw, 0.95rem);
  cursor: pointer;
  white-space: nowrap;
  overflow: visible;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.ach-tab:not(.is-active) {
  background: rgba(2, 5, 10, 0.52);
}

.ach-tab:hover,
.ach-tab:focus-visible {
  outline: none;
  background: color-mix(in oklch, var(--ach-gold) 18%, transparent);
}

.ach-tab.is-active {
  border-color: var(--ach-gold);
  background: linear-gradient(180deg, rgba(132, 101, 27, 0.58), rgba(37, 29, 12, 0.88));
  color: #fff8e7;
  box-shadow: inset 0 0 18px color-mix(in oklch, var(--ach-gold) 35%, transparent);
}

.ach-tab.ach-tier--grandmaster.is-active {
  border-color: var(--ach-grandmaster);
  background: color-mix(in oklch, var(--ach-grandmaster) 30%, transparent);
  box-shadow: inset 0 0 18px color-mix(in oklch, var(--ach-grandmaster) 40%, transparent);
}

@media (max-width: 1100px) {
  .ach-tabs-bar {
    display: flex;
    overflow-x: auto;
    gap: 0.35rem;
    min-height: 3.25rem;
    background-size: 100% 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .ach-tab {
    flex: 0 0 auto;
    padding: 0.55rem 0.95rem;
    font-size: 0.88rem;
  }
}

/* ========== Filters (wide | game | status | icon) ========== */
.ach-filters-bar {
  display: grid;
  grid-template-columns: minmax(12rem, 1.6fr) minmax(9.5rem, 0.9fr) minmax(9.5rem, 0.9fr) auto;
  gap: 0.5rem;
  align-items: center;
  min-height: 3.75rem;
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.7rem;
  background:
    linear-gradient(rgba(7, 11, 19, 0.9), rgba(7, 11, 19, 0.94)),
    url("/images/achievements/achievements-filters-bar-bg.webp") center / cover no-repeat;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 26%, transparent);
  border-radius: 0.75rem;
}

.ach-search {
  position: relative;
  display: block;
  min-width: 0;
}

.ach-search__icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ach-muted);
  pointer-events: none;
}

.ach-search__input,
.ach-select {
  width: 100%;
  min-height: 42px;
  border-radius: 0.4rem;
  border: 1px solid color-mix(in oklch, white 15%, transparent);
  background: rgba(2, 5, 10, 0.72);
  color: var(--ach-ink);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.45rem 0.65rem;
  text-overflow: clip;
}

.ach-search__input { padding-left: 2.25rem; }

.ach-search__input:focus-visible,
.ach-select:focus-visible,
.ach-filter-more:focus-visible {
  outline: 2px solid color-mix(in oklch, #60a5fa 75%, transparent);
  outline-offset: 1px;
}

.ach-filter-field { min-width: 0; }

.ach-filter-more {
  width: 44px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 0.4rem;
  border: 1px solid color-mix(in oklch, white 15%, transparent);
  background: rgba(2, 5, 10, 0.72);
  color: var(--ach-ink);
  cursor: pointer;
  justify-self: center;
}

@media (max-width: 700px) {
  .ach-filters-bar {
    grid-template-columns: 1fr 1fr auto;
    background-size: 100% 100%;
    padding: 0.65rem;
    gap: 0.45rem;
  }

  .ach-search { grid-column: 1 / -1; }
}

/* ========== Section header ========== */
.ach-section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: space-between;
  align-items: center;
  min-height: 3.25rem;
  margin-bottom: 0.85rem;
  padding: 0.55rem 1rem;
  background:
    linear-gradient(rgba(7, 11, 19, 0.86), rgba(7, 11, 19, 0.94)),
    url("/images/achievements/achievements-section-header-bg.webp") center / cover no-repeat;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 30%, transparent);
  border-radius: 0.7rem;
}

.ach-section-head__left,
.ach-section-head__right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.ach-section-head__title {
  font-family: var(--ach-font-display);
  font-size: 1.1rem;
  margin: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

.ach-section-head__count {
  font-size: 0.88rem;
  color: var(--ach-muted);
  white-space: nowrap;
}

.ach-select--sort {
  min-width: 11rem;
  background: color-mix(in oklch, black 40%, transparent);
}

@media (max-width: 700px) {
  .ach-section-head {
    background-size: 100% 100%;
    padding: 0.65rem 0.85rem;
  }
}

/* ========== Cards (1672×760 — bronze/silver/gold/purple by tier) ========== */
.ach-layout {
  display: grid;
  gap: 1rem;
}

.ach-detail {
  display: none !important;
}

.ach-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .ach-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1400px) {
  .ach-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ach-card {
  position: relative;
  aspect-ratio: 1672 / 760;
  width: 100%;
  border: none;
  border-radius: 0;
  cursor: pointer;
  color: inherit;
  background: url("/images/achievements/achievement-card-bronze-bg.webp") center / 100% 100% no-repeat;
  transition: transform 0.15s ease, filter 0.15s ease;
  overflow: hidden;
}

.ach-card--tier-squire {
  background-image: url("/images/achievements/achievement-card-bronze-bg.webp");
}

.ach-card--tier-knight {
  background-image: url("/images/achievements/achievement-card-silver-bg.webp");
}

.ach-card--tier-paladin {
  background-image: url("/images/achievements/achievement-card-gold-bg.webp");
}

.ach-card--tier-grandmaster,
.ach-card--epic {
  background-image: url("/images/achievements/achievement-card-purple-bg.webp");
}

.ach-card:hover,
.ach-card:focus-visible {
  outline: none;
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.ach-card:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in oklch, #60a5fa 70%, transparent);
}

.ach-card--locked .ach-card__shield img,
.ach-card--secret .ach-card__shield img {
  filter: grayscale(0.55) brightness(0.72);
}

/* Text half of the baked top-right pill, to the right of its shield icon. */
.ach-card__tier {
  position: absolute;
  left: 77.2%;
  top: 12.6%;
  width: 16.2%;
  height: 10.2%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0.15rem;
  color: #f6efe2;
  font-size: clamp(0.48rem, 1.15vw, 0.7rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  text-align: center;
  background: transparent;
  border: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.ach-card--tier-grandmaster .ach-card__tier {
  left: 74.6%;
  letter-spacing: 0.01em;
}

.ach-card__main {
  display: contents;
}

/* Inner hole of the left medallion on the 1672×760 tier cards. */
.ach-card__shield {
  position: absolute;
  left: 17.8%;
  top: 41.2%;
  width: 17.2%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  background: transparent;
}

.ach-card__shield img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Open area to the right of the medallion, above the footer bar. */
.ach-card__copy {
  position: absolute;
  left: 34.5%;
  right: 4.5%;
  top: 24%;
  bottom: 24%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ach-card__name {
  margin: 0;
  font-size: clamp(0.82rem, 1.7vw, 1.05rem);
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.ach-card__desc {
  margin: 0.22rem 0 0;
  font-size: clamp(0.65rem, 1.25vw, 0.8rem);
  color: var(--ach-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Single-column cards are wide; the vw clamp otherwise stays at its floor. */
@media (max-width: 639px) {
  .ach-card__copy {
    top: 21.5%;
    bottom: 20.5%;
  }

  .ach-card__name {
    font-size: 1.15rem;
    line-height: 1.15;
  }

  .ach-card__desc {
    margin-top: 0.16rem;
    font-size: 1rem;
    line-height: 1.25;
  }
}

/* Recessed footer bar: y ~600–675 of 760. */
.ach-card__footer {
  position: absolute;
  left: 6%;
  right: 5.2%;
  top: 79.4%;
  height: 10%;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.ach-card .ach-progress {
  flex: 1 1 2rem;
  height: 0.28rem;
  min-width: 1.4rem;
}

.ach-card__meta {
  margin: 0;
  font-size: clamp(0.58rem, 1.05vw, 0.74rem);
  color: var(--ach-muted);
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem 0.45rem;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  white-space: nowrap;
}

.ach-card__earned-text { color: color-mix(in oklch, #86efac 80%, white); }

.ach-card__points {
  color: #f0d78c;
  font-weight: 700;
  margin-left: auto;
}

.ach-card[hidden] { display: none !important; }

.ach-detail {
  border-radius: 0.9rem;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 30%, transparent);
  background: #141018;
  padding: 1rem;
}

.ach-detail__close { margin-top: 0.75rem; }

/* Tailwind's margin reset overrides the browser's dialog centering (margin: auto). */
.ach-modal {
  position: fixed;
  inset: 0;
  width: min(28rem, calc(100vw - 1.5rem));
  max-width: min(28rem, calc(100vw - 1.5rem));
  height: fit-content;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  overflow: auto;
  border: none;
  border-radius: 1rem;
  padding: 0;
  background: transparent;
  color: var(--ach-ink);
}

.ach-modal::backdrop { background: color-mix(in oklch, black 65%, transparent); }

.ach-modal__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.2rem;
  background: #151018;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 35%, transparent);
  border-radius: 1rem;
  padding: 1.35rem 1.25rem 1.15rem;
}

.ach-modal__badge {
  width: 7.25rem;
  height: 7.25rem;
  display: grid;
  place-items: center;
  margin-bottom: 0.35rem;
}

.ach-modal__badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ach-modal__title {
  margin: 0;
  font-family: var(--ach-font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.ach-modal__subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f0d78c;
}

.ach-modal__desc {
  margin: 0.55rem 0 0;
  max-width: 24rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ach-muted);
}

.ach-modal__meta {
  width: 100%;
  margin-top: 0.85rem;
}

.ach-modal__meta .ach-card__meta {
  justify-content: center;
  gap: 0.65rem 1.1rem;
  font-size: 0.92rem;
}

.ach-modal__meta .ach-card__points { margin-left: 0; }

.ach-modal__meta .ach-progress {
  width: 100%;
  height: 0.45rem;
}

.ach-modal__actions {
  width: 100%;
  margin: 0.15rem 0 0;
}

.ach-modal__close {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.6rem 1rem;
  border-radius: 0.7rem;
  border: 1px solid color-mix(in oklch, var(--ach-gold) 55%, transparent);
  background: color-mix(in oklch, #d4af37 16%, #151018);
  color: #f3e6c5;
  font-weight: 700;
  cursor: pointer;
}

.ach-modal__close:hover,
.ach-modal__close:focus-visible {
  filter: brightness(1.12);
  outline: none;
}

/* Celebration overlay */
.ach-celebrate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in oklch, black 55%, transparent);
}

.ach-celebrate[hidden] { display: none !important; }

.ach-celebrate__panel {
  width: min(26rem, 100%);
  border-radius: 1rem;
  padding: 1.25rem 1.1rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, color-mix(in oklch, #d4af37 28%, transparent), transparent 60%),
    #141018;
  border: 1px solid color-mix(in oklch, #d4af37 40%, transparent);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  animation: ach-celebrate-in 0.45s ease;
  color: var(--ach-ink);
}

@keyframes ach-celebrate-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.ach-celebrate__title {
  font-family: var(--ach-font-display);
  text-align: center;
  margin: 0 0 0.85rem;
  letter-spacing: 0.06em;
  font-size: 1.05rem;
  color: #f3e6c5;
}

.ach-celebrate__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ach-celebrate__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: start;
  padding: 0.55rem 0.5rem;
  border-radius: 0.65rem;
  background: color-mix(in oklch, white 5%, transparent);
}

.ach-celebrate__total {
  margin: 0.9rem 0 0;
  text-align: center;
  font-weight: 800;
  color: #d4af37;
}

@media (prefers-reduced-motion: reduce) {
  .ach-celebrate__panel,
  .ach-card {
    animation: none !important;
    transition: none !important;
  }
}
