:root {
  --orange: #F37A20;
  --navy: #001f4d;
  --lightorange: #f4a460;
  --text: #444;
  --bg: #f9f9f9;
}

h2 { font-weight: 600; margin-bottom: 20px; color: #333; }

.diagram {
  position: relative;
  width: 800px;
  height: 800px;
  margin: 0 auto;
}

.center-logo {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 220px; height: 220px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #ddd;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  display: flex; align-items: center; justify-content: center;
  z-index: 2; overflow: hidden;
}
.center-logo img { width: 80%; height: auto; }

.entity {
  position: absolute;
  width: 170px; height: 170px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #ddd;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 2;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  flex-direction: column;
  overflow: visible;
}
.entity img { width: 90px; height: 40px; margin-top: 10px; }
.entity .dot {
  position: absolute; top: 90px; right: -6px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.dot.orange { background: var(--orange); }
.dot.navy { background: var(--navy); }
.dot.lightorange { background: var(--lightorange); }

.entity-text { margin-top: 8px; font-size: 12px; color: #555; text-align: center; max-width: 140px; }

.entity:hover {
  box-shadow: 0 8px 16px rgba(0,0,0,0.18);
  transform: scale(1.08);
  border-color: var(--orange);
}

.tooltip {
  position: absolute;
  top: 130px; left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #ddd;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 10px;
  border-radius: 6px;
  width: 240px;
  font-size: 11px;
  line-height: 1.5;
  display: none;
  z-index: 10;
  pointer-events: none;
}

svg.connector {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}
line { stroke: #f0f0f0; stroke-width: 1.5; transition: stroke 0.25s ease; }
line.hovered { stroke: var(--orange); }

.legend { margin-top: 30px; }
.legend span { margin: 0 15px; font-size: 14px; }
.legend .dot { position: relative; top: 2px; margin-right: 5px; }
.caption { margin-top: 15px; font-style: italic; color: #555; }

/* --- Responsive Tree Layout --- */
@media (max-width: 480px) {
  .diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 10px;
    position: relative; /* needed for trunk line */
  }

  /* vertical trunk line from logo down */
  .diagram::before {
    content: "";
    position: absolute;
    top: 140px; /* just below center logo */
    bottom: 0;
    left: 50%;
    width: 2px;
    background: #ddd;
    transform: translateX(-50%);
    z-index: 0;
  }

  .center-logo {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    margin: 0 auto 20px auto;
    width: 120px; height: 120px;
    z-index: 1;
  }

  .entity {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    margin: 20px auto !important;
    width: 90%;
    max-width: 320px;
    height: auto;
    border-radius: 8px;
    display: block;
    text-align: center;
    padding: 10px;
    background: #fff;
    z-index: 1;
  }

  /* connector line from trunk to each entity */
  .entity::before {
    content: "";
    position: absolute;
    top: -20px; /* connects to trunk above */
    left: 50%;
    width: 2px;
    height: 20px;
    background: #ddd;
    transform: translateX(-50%);
    z-index: 0;
  }

  .entity img {
    display: block;
    margin: 0 auto 10px auto;
    width: 40px;
    height: auto;
  }

  .entity .dot {
    position: absolute;
    right: 10px;
    top: 10px;
  }

  .entity-text {
    margin: 5px 0;
    font-size: 14px;
    font-style: normal;
  }

  .tooltip {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: block !important;
    margin-top: 6px;
    width: 100%;
    box-shadow: none;
    border: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
    text-align: center;
  }

  svg.connector { display: none; }
}
