.family-tree-page,
.family-tree-page * {
  box-sizing: border-box;
}

body.family-tree-page {
  margin: 0;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  background: #17110b;
  color: #f5f0e6;
}

.family-tree-page,
.family-tree-page button,
.family-tree-page p,
.family-tree-page strong,
.family-tree-page select,
.family-tree-page label,
.family-tree-page h1,
.family-tree-page h2,
.family-tree-page h3 {
  font-family: Georgia, "Times New Roman", serif;
}

.family-tree-page .hidden {
  display: none !important;
}

.family-tree-page #tree {
  position: relative;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at top, rgba(183, 137, 68, 0.18), transparent 45%),
    linear-gradient(135deg, #1d150d, #0f0a06 70%);
  overflow: hidden;
}

.family-tree-page #family-tree-host {
  position: absolute;
  inset: 0;
}

.family-tree-page .atlas-map-nav {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 15;
  display: flex;
  flex-direction: row;
  gap: 10px;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  align-items: flex-start;
  font-family: Arial, sans-serif;
}

.family-tree-page .atlas-map-nav__menu {
  position: relative;
}

.family-tree-page .atlas-map-nav__menu summary {
  list-style: none;
  cursor: pointer;
}

.family-tree-page .atlas-map-nav__menu summary::-webkit-details-marker {
  display: none;
}

.family-tree-page .atlas-map-nav__link,
.family-tree-page .atlas-map-nav__toggle,
.family-tree-page #reset-view,
.family-tree-page .back-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(218, 184, 112, 0.55);
  border-radius: 999px;
  background: rgba(31, 22, 13, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: #f5e6c8;
  text-decoration: none;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1;
}

.family-tree-page .tree-view-panel select {
  padding: 10px 14px;
  border: 1px solid rgba(218, 184, 112, 0.55);
  border-radius: 999px;
  background: rgba(31, 22, 13, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: #f5e6c8;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.3;
}

.family-tree-page .atlas-map-nav__toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.family-tree-page .atlas-map-nav__dropdown {
  display: grid;
  gap: 8px;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  min-width: max-content;
  max-width: calc(100vw - 24px);
  z-index: 16;
}

.family-tree-page .atlas-map-nav__link > span,
.family-tree-page .atlas-map-nav__toggle-label > span {
  font-family: inherit;
}

.family-tree-page .atlas-map-nav__link .material-icons,
.family-tree-page .atlas-map-nav__toggle .material-icons {
  font-size: 20px;
}

.family-tree-page .atlas-map-nav__link--current {
  background: rgba(111, 72, 32, 0.92);
}

.family-tree-page .atlas-map-nav__menu[open] .atlas-map-nav__chevron {
  transform: rotate(180deg);
}

.family-tree-page .atlas-map-nav__link:hover,
.family-tree-page .atlas-map-nav__link:focus-visible,
.family-tree-page .atlas-map-nav__toggle:hover,
.family-tree-page .atlas-map-nav__toggle:focus-visible,
.family-tree-page #reset-view:hover,
.family-tree-page #reset-view:focus-visible,
.family-tree-page .back-button:hover,
.family-tree-page .back-button:focus-visible,
.family-tree-page .tree-view-panel select:hover,
.family-tree-page .tree-view-panel select:focus-visible {
  background: rgba(47, 33, 18, 0.95);
}

.family-tree-page #reset-view,
.family-tree-page .back-button {
  cursor: pointer;
}

.family-tree-page .tree-view-panel {
  position: absolute;
  top: 104px;
  left: 18px;
  z-index: 13;
  width: min(380px, calc(100vw - 36px));
  padding: 18px;
  border: 1px solid rgba(218, 184, 112, 0.35);
  border-radius: 22px;
  background: rgba(10, 7, 4, 0.7);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.family-tree-page .tree-view-panel__eyebrow,
.family-tree-page .tree-empty-state__eyebrow {
  margin: 0 0 10px;
  color: #d7b36c;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.family-tree-page .tree-view-panel h1 {
  margin: 0 0 14px;
  color: #f8e7bc;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
}

.family-tree-page .tree-view-panel__field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.family-tree-page .tree-view-panel__field span {
  color: #ead7a8;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.family-tree-page .tree-view-panel select {
  width: 100%;
  appearance: none;
  cursor: pointer;
}

.family-tree-page .tree-view-panel__description,
.family-tree-page .tree-view-panel__stats {
  margin: 0;
  line-height: 1.55;
}

.family-tree-page .tree-view-panel__description {
  color: #f1e2bf;
  font-size: 15px;
}

.family-tree-page .tree-view-panel__stats {
  margin-top: 12px;
  color: #d7b36c;
  font-family: Arial, sans-serif;
  font-size: 13px;
}

.family-tree-page .tree-empty-state {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 32px;
}

.family-tree-page .tree-empty-state__card {
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid rgba(218, 184, 112, 0.35);
  border-radius: 24px;
  background: rgba(10, 7, 4, 0.82);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.family-tree-page .tree-empty-state h2 {
  margin: 0 0 12px;
  color: #f8e7bc;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.family-tree-page .tree-empty-state p:last-child {
  margin: 0;
  color: #f0dfbd;
  font-size: 18px;
  line-height: 1.6;
}

.family-tree-page .hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 11;
  padding: 8px 14px;
  border: 1px solid rgba(218, 184, 112, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #e8d3a6;
  font-family: Arial, sans-serif;
  font-size: 13px;
  pointer-events: none;
}

.family-tree-page .character-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  background:
    radial-gradient(circle at top left, rgba(183, 137, 68, 0.22), transparent 35%),
    linear-gradient(135deg, #21170e, #090604 75%);
  color: #f5f0e6;
  overflow-y: auto;
}

.family-tree-page .character-sheet__inner {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 60px;
}

.family-tree-page .back-button {
  margin-bottom: 34px;
  background: rgba(31, 22, 13, 0.8);
}

.family-tree-page .character-header,
.family-tree-page .character-section {
  border: 1px solid rgba(218, 184, 112, 0.35);
  border-radius: 24px;
  background: rgba(255, 244, 222, 0.07);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.family-tree-page .character-header {
  display: flex;
  gap: 30px;
  align-items: center;
  padding: 30px;
}

.family-tree-page .character-header__portrait-button {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: zoom-in;
}

.family-tree-page .character-header__portrait-button:focus-visible {
  outline: 3px solid rgba(244, 220, 166, 0.9);
  outline-offset: 6px;
}

.family-tree-page .character-header img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #b78944;
  background: #efe1c4;
}

.family-tree-page .character-header h1 {
  margin: 0 0 8px;
  color: #f7dfaa;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.95;
}

.family-tree-page .character-header h2 {
  margin: 0;
  color: #d7b36c;
  font-weight: normal;
  font-size: clamp(18px, 2.5vw, 28px);
}

.family-tree-page .character-note {
  margin: 14px 0 0;
  color: #edd8ac;
  font-size: 16px;
  line-height: 1.55;
}

.family-tree-page .character-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 24px 0;
}

.family-tree-page .meta-card,
.family-tree-page .relation-card {
  padding: 18px;
  border: 1px solid rgba(218, 184, 112, 0.32);
  border-radius: 18px;
  background: rgba(255, 244, 222, 0.06);
  color: #f0dfbd;
}

.family-tree-page .meta-card strong,
.family-tree-page .relation-card strong {
  display: block;
  margin-bottom: 8px;
  color: #d7b36c;
  font-family: Arial, sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.family-tree-page .character-section {
  padding: 26px 30px;
  margin-top: 22px;
  color: #f5e9cf;
  font-size: 20px;
  line-height: 1.65;
}

.family-tree-page .character-section h3 {
  margin: 0 0 14px;
  color: #f6dfaf;
  font-size: 22px;
}

.family-tree-page .character-section p {
  margin: 0;
}

.family-tree-page .portrait-lightbox {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 4, 2, 0.88);
  backdrop-filter: blur(6px);
}

.family-tree-page .portrait-lightbox__dialog {
  position: relative;
  width: min(1100px, 100%);
  max-height: 100%;
  padding: 54px 24px 24px;
  border: 1px solid rgba(218, 184, 112, 0.35);
  border-radius: 24px;
  background: rgba(26, 17, 9, 0.78);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.family-tree-page .portrait-lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(218, 184, 112, 0.42);
  border-radius: 999px;
  background: rgba(255, 244, 222, 0.08);
  color: #f5e6c8;
  cursor: pointer;
  font-size: 14px;
}

.family-tree-page .portrait-lightbox__close:hover,
.family-tree-page .portrait-lightbox__close:focus-visible {
  background: rgba(255, 244, 222, 0.16);
  border-color: rgba(218, 184, 112, 0.66);
}

.family-tree-page .portrait-lightbox__figure {
  display: grid;
  gap: 16px;
  margin: 0;
}

.family-tree-page .portrait-lightbox__image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(78vh, 920px);
  margin: 0 auto;
  border-radius: 20px;
  border: 1px solid rgba(218, 184, 112, 0.32);
  background: rgba(255, 244, 222, 0.06);
  object-fit: contain;
}

.family-tree-page .portrait-lightbox__caption {
  color: #f0dfbd;
  font-size: 17px;
  line-height: 1.5;
  text-align: center;
}

.family-tree-page .relation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.family-tree-page .relation-card span {
  display: block;
  line-height: 1.55;
}

.family-tree-page .tree-error-box {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 999;
  max-width: calc(100vw - 40px);
  padding: 16px;
  border: 1px solid #d7b36c;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #f5e6c8;
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .family-tree-page .character-meta,
  .family-tree-page .relation-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .family-tree-page .atlas-map-nav {
    top: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
  }

  .family-tree-page .tree-view-panel {
    top: 100px;
    left: 12px;
    width: calc(100vw - 24px);
  }

  .family-tree-page .hint {
    bottom: 12px;
    width: calc(100vw - 24px);
    text-align: center;
  }

  .family-tree-page .character-header {
    flex-direction: column;
    text-align: center;
  }

  .family-tree-page .portrait-lightbox {
    padding: 12px;
  }

  .family-tree-page .portrait-lightbox__dialog {
    padding: 56px 14px 16px;
  }

  .family-tree-page .portrait-lightbox__image {
    max-height: 72vh;
  }

  .family-tree-page .character-meta,
  .family-tree-page .relation-grid {
    grid-template-columns: 1fr;
  }
}
