/* Збереження оригінальної структури з точковими покращеннями */
body {
  font: normal 100 100%/1.5 helvetica, arial, sans-serif;
  perspective: 500px;
}

/* Контейнерні запити для дерева */
.tree {
  position: relative;
  container-type: inline-size;
  container-name: tree;
}

/* Використання вкладених селекторів для кращої читабельності */
.tree * {
  box-sizing: border-box;
  position: absolute;
  display: block;
  height: 4.5vw;
  bottom: -9vw;
  transform: translateX(5%);
  font-size: 0.95em;
  text-align: center;
  line-height: 4.5vw;
  border: 1px solid transparent;
  border-radius: 3px;
  background: #999;
  color: #fff;
  transition: all 0.3s;
}

/* Використання :has для реагування на наведення */
.tree:has(*:hover) * {
  /* Легкий ефект для всіх елементів коли миша на одному з них */
  filter: brightness(0.95);
}

.tree *:hover {
  background: #27f;
  border-color: black;
  cursor: pointer;
}

.tree *:hover::before {
  background: black;
}

.tree *::before {
  content: "";
  position: absolute;
  top: -4.5vw;
  left: 50%;
  transform: translate(-5%);
  width: 2px;
  height: calc(4.5vw - 1px);
  background: inherit;
}

/* Використання контейнерних запитів замість медіа-запитів */
@container tree (max-width: 500px) {
  .tree {
    width: 175%;
  }

  .tree * {
    height: 30px;
    bottom: -60px;
    line-height: 30px;
  }

  .tree *::before {
    top: -30px;
    height: 29px;
  }
}

@container tree (max-width: 300px) {
  .tree {
    width: 250%;
  }
}

/* Зворотна сумісність для браузерів, які не підтримують container queries */
@supports not (container-type: inline-size) {
  @media (max-width: 500px) {
    .tree {
      width: 175%;
    }

    .tree * {
      height: 30px;
      bottom: -60px;
      line-height: 30px;
    }

    .tree *::before {
      top: -30px;
      height: 29px;
    }
  }

  @media (max-width: 300px) {
    .tree {
      width: 250%;
    }
  }
}

/* *,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

#root,
#__next {
  isolation: isolate;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font: normal 100 100%/1.5 helvetica, arial, sans-serif;
  perspective: 500px;
}

.tree {
  position: relative;
}

.tree * {
  box-sizing: border-box;
  position: absolute;
  display: block;
  height: 4.5vw;
  bottom: -9vw;
  transform: translateX(5%);
  font-size: 0.95em;
  text-align: center;
  line-height: 4.5vw;
  border: 1px solid transparent;
  border-radius: 3px;
  background: #999;
  color: #fff;
  transition: all 0.3s;
}

.tree *:hover {
  background: #27f;
  border-color: black;
  cursor: pointer;
}

.tree *:hover::before {
  background: black;
}

.tree *::before {
  content: "";
  position: absolute;
  top: -4.5vw;
  left: 50%;
  transform: translate(-5%);
  width: 2px;
  height: calc(4.5vw - 1px);
  background: inherit;
}

@media (max-width: 500px) {
  .tree {
    width: 175%;
  }

  .tree * {
    height: 30px;
    bottom: -60px;
    line-height: 30px;
  }

  .tree *::before {
    top: -30px;
    height: 29px;
  }
}

@media (max-width: 300px) {
  .tree {
    width: 250%;
  }
} */