.crystal-guide {
  --crystal-gold: #e4bf7b;
  --crystal-ember: #f2af78;
  --crystal-deterrence: #eba9ab;
  padding-bottom: 48px;
}

.crystal-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px;
  margin: 24px 0 40px;
  padding: clamp(24px, 5vw, 56px);
  border: 1px solid #4c4032;
  background: radial-gradient(ellipse at 89% 34%, #393027, transparent 54%), #171819;
}

.crystal-hero .eyebrow {
  margin: 0;
}

.crystal-hero h1 {
  margin: 12px 0 16px;
  font-size: clamp(2.65rem, 7vw, 6rem);
  line-height: .92;
}

.crystal-hero h1 span {
  display: block;
}

.crystal-hero p:last-child {
  max-width: 52ch;
  margin: 0;
  color: #ccc2b3;
}

.crystal-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(100px, 19vw, 220px);
  aspect-ratio: 1;
}

.crystal-emblem::before,
.crystal-emblem::after {
  content: '';
  position: absolute;
  width: 65%;
  aspect-ratio: 1;
  border: 1px solid #89704a;
  transform: rotate(45deg);
}

.crystal-emblem::after {
  width: 53%;
  border-color: #5a4935;
}

.crystal-emblem span {
  width: 42%;
  aspect-ratio: 3 / 4;
  background: conic-gradient(from 0deg at 51% 43%, #d5ac6b 0 55deg, #805e38 55deg 135deg, #ac7846 135deg 180deg, #c79f68 180deg 223deg, #f3d9a6 223deg 307deg, #a47b49 307deg);
  clip-path: polygon(50% 0, 100% 34%, 91% 69%, 50% 100%, 9% 69%, 0 34%);
}

.crystal-section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 16px;
}

.crystal-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crystal-shortcuts[hidden],
.crystal-tree[hidden] {
  display: none;
}

.crystal-shortcuts a {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #574435;
  color: var(--crystal-ember);
  font-size: .82rem;
}

.crystal-shortcuts a.jump-deterrence {
  border-color: #654448;
  color: var(--crystal-deterrence);
}

.crystal-shortcuts a:hover {
  border-color: currentColor;
}

.crystal-tree {
  --tree-gap: clamp(6px, 2vw, 24px);
  --connector: #806b4f;
  padding: clamp(10px, 3vw, 34px);
  border: 1px solid #383330;
  background: repeating-linear-gradient(90deg, transparent 0 37px, #ffffff05 37px 38px), #141516;
}

.crystal-tier,
.crystal-connector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--tree-gap);
  max-width: 840px;
  margin-inline: auto;
}

.crystal-tier {
  scroll-margin-top: 16px;
}

.crystal-connector {
  position: relative;
  height: clamp(19px, 3.2vw, 36px);
}

.crystal-connector.has-junction::before {
  content: '';
  position: absolute;
  top: 50%;
  inset-inline: calc((100% - 2 * var(--tree-gap)) / 6);
  height: 1px;
  background: var(--connector);
}

.crystal-stem {
  position: relative;
}

.crystal-stem::before,
.crystal-stem::after {
  position: absolute;
  left: 50%;
  width: 1px;
  background: var(--connector);
}

.crystal-stem.from-above::before {
  content: '';
  top: 0;
  bottom: 50%;
}

.crystal-stem.to-below::after {
  content: '';
  top: 50%;
  bottom: 0;
}

.crystal-card {
  --card-accent: #c3c6c5;
  --card-border: #414446;
  --card-bg: #202224;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  grid-column: var(--column);
  min-width: 0;
  min-height: 112px;
  padding: 13px 14px;
  border: 1px solid var(--card-border);
  border-radius: 3px;
  color: var(--text);
  background: var(--card-bg);
  text-align: left;
  cursor: pointer;
}

.crystal-card.slot {
  --card-accent: var(--crystal-gold);
  --card-border: #66573e;
  --card-bg: #25221d;
}

.crystal-card.enrage {
  --card-accent: #dfbb99;
  --card-border: #694937;
  --card-bg: #29201d;
}

.crystal-card.enrage-atk {
  --card-accent: var(--crystal-ember);
  --card-border: #aa7047;
  --card-bg: #35241d;
  border-top: 2px solid var(--card-border);
}

.crystal-card.deterrence {
  --card-accent: var(--crystal-deterrence);
  --card-border: #81555b;
  --card-bg: #2b2024;
}

.crystal-card:hover {
  border-color: var(--card-accent);
  box-shadow: inset 0 0 0 1px var(--card-accent);
}

.crystal-card:focus-visible,
.crystal-close:focus-visible {
  outline-offset: 2px;
}

.crystal-card-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-bottom: 2px;
  border: 1px solid var(--card-border);
  color: var(--card-accent);
  font-family: 'Segoe UI Symbol', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1;
}

.crystal-card-name {
  font-size: clamp(.76rem, 1.7vw, 1.02rem);
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.crystal-card-summary {
  margin-top: auto;
  padding-top: 3px;
  color: var(--card-accent);
  font-size: clamp(.67rem, 1.45vw, .83rem);
  line-height: 1.25;
}

.crystal-card-open {
  position: absolute;
  top: 10px;
  right: 12px;
  color: var(--card-accent);
  font-size: .85rem;
}

.crystal-dialog {
  --dialog-accent: var(--crystal-gold);
  width: min(36rem, calc(100% - 24px));
  max-height: min(48rem, calc(100dvh - 24px));
  padding: 0;
  border: 1px solid #776447;
  border-top: 3px solid var(--dialog-accent);
  border-radius: 4px;
  background: #191a1b;
  color: var(--text);
  overflow: hidden;
}

.crystal-dialog[open] {
  display: flex;
  flex-direction: column;
}

.crystal-dialog.is-expanded {
  width: min(76rem, calc(100% - 24px));
}

.crystal-dialog[data-kind^='enrage'] {
  --dialog-accent: var(--crystal-ember);
}

.crystal-dialog[data-kind='deterrence'] {
  --dialog-accent: var(--crystal-deterrence);
}

.crystal-dialog::backdrop {
  background: #09090bd9;
}

.crystal-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 20px clamp(12px, 4vw, 24px) 14px;
  border-bottom: 1px solid #3d3834;
}

.crystal-dialog-header .eyebrow {
  margin: 0 0 6px;
  color: var(--dialog-accent);
}

.crystal-dialog-header h2 {
  font-size: clamp(1.55rem, 6vw, 2.25rem);
}

.crystal-close {
  width: 44px;
  height: 44px;
  border: 1px solid #625746;
  border-radius: 3px;
  background: #24211e;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.crystal-close:hover {
  border-color: var(--dialog-accent);
}

.crystal-dialog-body {
  min-height: 0;
  padding: 14px clamp(12px, 4vw, 24px) 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.crystal-dialog-body > p {
  margin: 0 0 12px;
  color: #d1c9bd;
}

.crystal-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0;
}

.crystal-facts div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.crystal-facts dt {
  color: #c7beb2;
  font-size: .82rem;
}

.crystal-facts dd {
  margin: 0;
  color: var(--dialog-accent);
  font-weight: 650;
}

.crystal-dialog-actions:not([hidden]) {
  display: flex;
  justify-content: flex-end;
  padding: 12px clamp(12px, 4vw, 24px);
  border-top: 1px solid #3d3834;
}

.crystal-info-toggle {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #796142;
  border-radius: 3px;
  background: #30271e;
  color: var(--dialog-accent);
  font-size: .88rem;
  font-weight: 650;
  cursor: pointer;
}

.crystal-info-toggle:hover {
  border-color: currentColor;
}

.crystal-info-toggle:focus-visible,
.crystal-table-scroll:focus-visible {
  outline: 2px solid var(--dialog-accent);
  outline-offset: 2px;
}

.crystal-levels {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: .85rem;
  line-height: 1.25;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.crystal-levels :is(th, td) {
  padding: 7px 8px;
  border-bottom: 1px solid #3a3633;
}

.crystal-levels thead {
  color: #ded5c6;
  background: #292724;
}

.crystal-levels tbody tr:nth-child(even) {
  background: #ffffff06;
}

.crystal-levels tbody tr:last-child {
  color: var(--dialog-accent);
  font-weight: 700;
  background: #ffffff0e;
}

#crystal-details-heading {
  font-size: 1.4rem;
}

.crystal-table-scroll {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid #3a3633;
}

.crystal-levels-wide {
  min-width: 64rem;
  margin-top: 0;
  border-collapse: separate;
  border-spacing: 0;
  text-align: right;
  white-space: nowrap;
}

.crystal-levels-wide :is(th, td) {
  padding: 9px 12px;
}

.crystal-levels-wide th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 1px solid #4a443e;
  background: #191a1b;
  text-align: left;
}

.crystal-levels-wide thead th:first-child {
  background: #292724;
}

.crystal-levels-wide tbody tr:nth-child(even) th:first-child {
  background: #1e1f20;
}

.crystal-levels-wide tbody tr:last-child th:first-child {
  background: #262728;
}

.crystal-data-note {
  margin: 6px 0 0;
  color: #c7beb2;
  font-size: .78rem;
}

.crystal-summary:not([hidden]) {
  display: block;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 24px;
}

.crystal-summary > .eyebrow {
  margin: 0 0 8px;
}

.crystal-summary h3 {
  margin: 32px 0 14px;
  font-size: 1.5rem;
}

.crystal-total-coins {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 32px;
  padding: clamp(18px, 3vw, 32px);
  margin-top: 24px;
  border: 1px solid #8c7046;
  background: linear-gradient(115deg, #332a1d, #1e1c18);
}

.crystal-total-coins > div > span {
  color: #e6d9c2;
}

.crystal-total-coins strong {
  display: block;
  color: var(--crystal-gold);
  font-size: clamp(2.5rem, 6vw, 4rem);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.crystal-total-coins small {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 500;
}

.crystal-total-coins p {
  max-width: 28ch;
  margin: 0;
  color: #ded4c4;
}

.crystal-summary-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.crystal-summary-table :is(th, td) {
  padding: 14px clamp(8px, 2vw, 20px);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.crystal-summary-table thead {
  background: #25221e;
  color: #dbcfbc;
  font-size: .875rem;
}

.crystal-summary-table tbody th {
  font-weight: 500;
}

.crystal-summary-table small {
  display: block;
  margin-top: 3px;
  color: #bcb6ac;
  font-size: .875rem;
}

.crystal-summary-table td {
  color: var(--crystal-gold);
}

.crystal-summary-table:not(.crystal-bonus-summary) td {
  text-align: right;
  font-size: 1.25rem;
  font-weight: 650;
  white-space: nowrap;
}

.crystal-milestone {
  background: #272219;
}

.crystal-bonus-summary th {
  width: 40%;
}

.crystal-summary-note {
  margin: 14px 0 0;
  color: #c6c0b6;
  font-size: .875rem;
}

.crystal-summary-note strong {
  color: #e5d4b8;
}

.crystal-grand-total {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin: 18px 0 0;
  padding: 20px;
  border: 1px solid #78613f;
  background: #252018;
}

.crystal-grand-total > span {
  color: #d0c6b7;
}

.crystal-grand-total strong {
  color: var(--crystal-gold);
  font-variant-numeric: tabular-nums;
}

.crystal-scroll-hint {
  display: none;
}

@media (max-width: 1100px) {
  .crystal-scroll-hint {
    display: block;
  }
}

@media (max-width: 620px) {
  .crystal-hero {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 28px;
  }

  .crystal-emblem {
    display: none;
  }

  .crystal-section-head {
    flex-wrap: wrap;
    gap: 8px 16px;
  }

  .crystal-card {
    padding: 8px 6px;
  }

  .crystal-card-open {
    top: 6px;
    right: 6px;
  }

  .crystal-levels :is(th, td) {
    padding-inline: 5px;
  }
}

@media (max-width: 380px) {
  .family-crystal-page .nav {
    gap: 8px;
    font-size: .82rem;
  }

  .family-crystal-page .nav .discord {
    gap: 5px;
    padding-inline: 8px;
    font-size: inherit;
  }
}
