.realm-atlas {
  position: relative;
  isolation: isolate;
  min-width: 0;
  padding: clamp(18px, 3vw, 35px);
  border: 1px solid #61503b;
  border-radius: 15px;
  background-color: #171b24;
  background-image:
    linear-gradient(90deg, #121620e6, #171a24aa 46%, #121720d9),
    linear-gradient(0deg, #10151dc9, transparent 72%),
    url("./mountain.webp");
  background-size: cover;
  background-position: center, center, center 54%;
  box-shadow: 0 18px 30px #0004, inset 0 1px 0 #e6b77e26;
}

.realm-atlas-heading {
  position: relative;
  z-index: 1;
  margin: 0 0 16px;
}

.realm-atlas-heading h1 {
  color: var(--gold-light);
  font: bold clamp(34px, 4.5vw, 55px)/1.12 var(--serif);
  letter-spacing: .075em;
  margin: 4px 0 7px;
  text-shadow: 0 4px 20px #0008;
}

.realm-atlas-heading p:not(.eyebrow) {
  max-inline-size: 45ch;
  color: #e3d9cc;
}

.realm-atlas-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(14px, 3vw, 36px);
  align-items: center;
}

.realm-pyramid {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-width: 0;
  padding: 20px 0 8px;
  background: radial-gradient(ellipse at 50% 59%, #d6ab6540, transparent 69%);
}

.realm-pyramid::before,
.realm-pyramid::after {
  position: absolute;
  z-index: -1;
  display: block;
  pointer-events: none;
  content: "";
}

.realm-pyramid::before {
  inset: 6px auto auto 50%;
  width: 7px;
  height: 7px;
  transform: translateX(-50%) rotate(45deg);
  background: #f6d4a4;
  box-shadow: 0 0 13px 2px #e6b77ea6;
}

.realm-pyramid::after {
  bottom: 0;
  width: 94%;
  height: 30%;
  border-bottom: 1px solid #d5a36a59;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 72%, #19111780, transparent 72%);
}

.realm-tier {
  --rim: #9a7857;
  --upper: #312d34;
  --lower: #1d202b;
  --lean: 8.5%;
  --tier-width: 100%;
  --slope: polygon(var(--lean) 0, calc(100% - var(--lean)) 0, 100% 100%, 0 100%);
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  inline-size: var(--tier-width);
  min-block-size: 56px;
  padding: 5px 16px;
  color: #f1e4d4;
  border: 0;
  background: transparent;
  line-height: 1.17;
  text-align: center;
}

.realm-tier[data-tier="soul"] {
  --tier-width: 49%;
  --lean: 18%;
  --rim: #c8a77a;
  --upper: #51464c;
  --lower: #302a3c;
}

.realm-tier[data-tier="future"] {
  --tier-width: max(34%, 82px);
  --lean: 20%;
  --rim: #887c8b;
  --upper: #343849;
  --lower: #262735;
  color: #ddd1df;
}

.realm-tier[data-tier="core"] {
  --tier-width: 66%;
  --lean: 12.9%;
  --rim: #b38c60;
  --upper: #463c37;
  --lower: #282334;
}

.realm-tier[data-tier="foundation"] {
  --tier-width: 83%;
  --lean: 10.25%;
  --rim: #9d7d57;
  --upper: #36383d;
  --lower: #242730;
}

.realm-tier::before,
.realm-tier::after {
  position: absolute;
  pointer-events: none;
  clip-path: var(--slope);
  content: "";
}

.realm-tier::before {
  z-index: -2;
  inset: 0;
  background: linear-gradient(178deg, var(--rim), #75624e80 64%, #a98560);
}

.realm-tier::after {
  z-index: -1;
  inset: 1px 2px;
  background:
    linear-gradient(100deg, transparent 21%, #ffe2b51c 49%, transparent 76%),
    linear-gradient(180deg, var(--upper), var(--lower));
  transition: filter .16s ease, background-color .16s ease;
}

.realm-tier strong {
  color: inherit;
  font: bold clamp(20px, 2.5vw, 28px)/1 var(--serif);
  letter-spacing: .16em;
  text-indent: .16em;
}

.realm-tier small {
  max-inline-size: 100%;
  color: #e4d1bacc;
  font-size: 11px;
  letter-spacing: .06em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.realm-tier:hover::after,
.realm-tier:focus-visible::after {
  filter: brightness(1.2);
}

.realm-tier[aria-pressed="true"] {
  color: #2b1c11;
}

.realm-tier[aria-pressed="true"]::before {
  background: #fff0c9;
}

.realm-tier[aria-pressed="true"]::after {
  background:
    linear-gradient(115deg, #b27949a0, transparent 36%, #fff0c56b 54%, transparent 78%),
    linear-gradient(0deg, #b98251, #efd2a0);
}

.realm-tier[aria-pressed="true"] small { color: #302016; }
.realm-tier[data-tier="future"][aria-pressed="true"] { color: #f0e6f4; }
.realm-tier[data-tier="future"][aria-pressed="true"]::before { background: #c0adca; }
.realm-tier[data-tier="future"][aria-pressed="true"]::after {
  background: linear-gradient(174deg, #4d4458, #302c40);
}
.realm-tier[data-tier="future"] small { color: #cfc2d6; }
.realm-tier[data-current]:not([aria-pressed="true"]) strong { color: #ffdca8; }
.realm-tier[data-current]:not([aria-pressed="true"])::before { background: #e9b676; }
.realm-tier:focus-visible { outline-offset: 2px; }

.realm-insight {
  min-width: 0;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 8px;
  min-block-size: 205px;
  padding: clamp(15px, 2.5vw, 24px);
  border: 1px solid #b18b5e64;
  border-radius: 11px;
  background: linear-gradient(140deg, #2c2326f5, #151a25f2);
  box-shadow: 0 9px 20px #08091061;
}

.realm-insight-status {
  display: inline-block;
  padding: 2px 7px;
  color: #ead5ba;
  background: #4c3728;
  border: 1px solid #a581587d;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 650;
}

.realm-insight :is(h2, h3) {
  margin: 1px 0 0;
  color: #ffdbab;
  font: bold clamp(23px, 3vw, 33px)/1.1 var(--serif);
  letter-spacing: .12em;
}

.realm-insight-rule { color: #f0e5d7; }
.realm-insight-example { color: #d4c5b7; font-size: 12px; }

.realm-insight-progress {
  width: 100%;
  min-width: 0;
  margin-top: 3px;
  color: #f0c998;
  font-size: 12px;
  font-weight: 650;
}

.realm-insight-progress .meter { background: #564e55; margin: 6px 0 2px; }
.realm-insight-progress .meter span { background: linear-gradient(90deg, #ba8457, #ffd99d); }
.realm-insight-progress > strong { margin-inline-start: 7px; }

.realm-insight-arts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 6px 0 0;
  padding: 0;
  color: #d4c5b7;
  font-size: 12px;
  list-style: none;
}

.realm-insight-arts [data-mastered] { color: #ffdbab; }

.art-course-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-block: 6px;
}

@media (max-width: 790px) {
  .realm-atlas-grid { gap: 16px; }
}

@media (max-width: 620px) {
  .realm-atlas {
    padding: clamp(14px, 4vw, 22px);
    background-position: center, center, 61% center;
  }

  .realm-atlas-heading { margin-bottom: 12px; }
  .realm-atlas-heading h1 { font-size: clamp(29px, 8vw, 36px); }
  .realm-atlas-heading p:not(.eyebrow) { font-size: 13px; }

  .realm-atlas-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .realm-pyramid {
    width: min(100%, 420px);
    justify-self: center;
    gap: 5px;
    padding: 18px 0 7px;
  }

  .realm-tier {
    min-block-size: 48px;
    padding-inline: 9px;
  }

  .realm-tier strong { font-size: clamp(18px, 4.9vw, 22px); }

  .realm-insight {
    gap: 7px;
    min-block-size: 0;
    padding: 13px;
  }

  .realm-insight-rule { line-height: 1.6; }

  .realm-insight-arts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .realm-tier::after { transition: none; }
}
