:root {
  --main-theme-900: #1A1A2E;
  --main-theme-800: #3E3E5E;
  --main-theme-700: #3f3f46;
  --main-theme-600: #52525b;
  --main-theme-500: #71717a;
  --main-theme-400: #a1a1aa;
  --main-theme-300: #d4d4d8;
  --main-theme-200: #e4e4e7;
  --main-theme-100: #f4f4f5;
  --main-theme-50: #fafafa;
}

*,
::after,
::before {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  line-height: 1.15;
  height: 100vh;
}

body {
  font-family: "Trebuchet MS", sans-serif;
  /* фон страницы — общий, задаётся в ../common/site-common.css */
  height: 100%;
}

h1 {
  font-size: 1.5rem;
  color: var(--main-theme-300);
}

button:focus {
  outline: 0;
}

#calculator-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.calculator {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 450px;
  gap: 1rem;
  margin: 2rem 0;
}

.calculator-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  /* тёплый тёмно-коричневый: на старом сине-сером #3E3E5E игровой цвет
     «Мифического» #4338ca терялся */
  background-color: #312919;
  border-radius: 10px;
  padding: 1rem;
  width: 100%;
}

/* грейды в два столбца по два пункта: русские названия в одну строку
   не помещались, а в один столбец список слишком длинный */
.calculator-input__item-type {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 0.5rem 2.5rem;
  margin: 1.5rem auto 0;
  width: auto;
}

.calculator-input__item-type > div {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.calculator-input__item-type > div label {
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: bold;
}

/* .calculator__item-type input {
  margin-right: 20px;
} */

label[for="rbtnHeroic"] {
  color: #38bdf8;
}

label[for="rbtnFable"] {
  color: #fcd34d;
}

label[for="rbtnEternal"] {
  color: #f59e0b;
}

label[for="rbtnMythical"] {
  /* цвет как в игре; читаемость обеспечивает тёплый тёмный фон панели (#312919) */
  color: #4338ca;
}

.calculator-input select {
  width: 48px;
  height: 48px;
  font-size: 1.125rem;
}

/* уровни предмета и заточки — в одну строку */
.calculator-input__levels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 2rem;
}

.calculator-input__levels > div {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem; /* небольшой отступ между подписью и списком */
  margin: 1rem 0 0;
  color: var(--main-theme-300);
}

.calculator-output {
  border-radius: 5px;
  overflow: hidden;
  width: 100%;
}

.calculator-output__list {
  overflow-y: scroll;
  max-height: 350px;
}

.calculator-output__list-item {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

.calculator-output__list-item div {
  padding: 5px 10px;
  flex: 1;
  /*text-align: center;*/
}

.calculator-output__list-item:nth-child(even) {
  background-color: var(--main-theme-200);
}

.calculator-output__list-item:nth-child(odd) {
  background-color: var(--main-theme-300);
}

.calculator-output__header {
  /* в один цвет с панелью калькулятора */
  background-color: #312919;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  padding: 0.5rem;
}

.calculator-output__header div {
  flex: 1;
  color: var(--main-theme-300);
}

::-webkit-scrollbar {
  width: 15px;
}

::-webkit-scrollbar-track {
  background-color: var(--main-theme-300);
  box-shadow: inset 0 0 5px grey;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: var(--main-theme-600);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--main-theme-700);
}

::-webkit-scrollbar-thumb:active {
  background: var(--main-theme-800);
}

@media only screen and (max-width: 600px) {
  .calculator {
    width: 100%;
    min-width: auto;
    padding: 0 0.5rem;
  }
}

/* --- Телефон в ландшафте (низкий экран) --------------------------------
   Десктопное #calculator-wrapper центрирует колонку по вертикали: когда
   контент выше экрана, верх (заголовок и радиобаттоны) уходит за верхний
   край, и прокруткой его не достать — у переполненного flex-контейнера
   с центрированием верхняя часть недостижима. Выравниваем по верху,
   страница прокручивается естественно. Десктоп не затронут: высота окна
   десктопа >= 600px. */
@media only screen and (max-height: 599px) {
  #calculator-wrapper {
    justify-content: flex-start;
  }

  .calculator {
    margin: 0.8rem 0;
  }
}

/* --- Мобильная версия (телефоны) --------------------------------------
   Десктоп не затронут: правила только до 520px. */
@media only screen and (max-width: 520px) {
  h1 {
    font-size: 1.15rem;
    text-align: center;
    /* не наезжаем на кнопку «Назад» (слева) и флаги языка (справа) */
    padding: 0 48px;
  }

  #calculator-wrapper {
    justify-content: flex-start;
  }

  .calculator {
    margin: 1rem 0;
    gap: 0.7rem;
  }

  .calculator-input {
    padding: 0.8rem 0.6rem;
  }

  .calculator-input__item-type {
    gap: 0.4rem 1.4rem;
    margin-top: 1rem;
  }

  .calculator-input__item-type > div label {
    font-size: 1rem;
  }

  .calculator-input select {
    width: 44px;
    height: 44px;
    /* 16px+ — иначе iOS увеличивает страницу при фокусе списка */
    font-size: 16px;
  }

  .calculator-input__levels {
    gap: 0 1rem;
  }

  .calculator-input__levels > div {
    font-size: 0.95rem;
  }

  .calculator-output__list {
    max-height: 46vh;
  }

  /* таблица шансов тянется до самого низа экрана: колонка калькулятора
     растягивается на свободную высоту, список прокручивается внутри.
     min-height:0 на каждом flex-уровне обязателен — иначе элементы не
     сжимаются ниже своей контентной высоты и растягивают страницу */
  .calculator {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0.5rem 0 0;
    padding-bottom: 6px;
  }

  .calculator-output {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .calculator-output__list {
    flex: 1;
    max-height: none;
    /* иначе список не сжимается ниже своей/content-высоты и растягивает
       страницу — прокрутка должна быть внутри списка */
    min-height: 0;
  }
}
