/* ========== Root variables ========== */
:root {
  --bg: #f9f9f9;
  --text: #111;
  --panel: #fff;
  --header-bg: #ddd;
  --accent-main: linear-gradient(135deg, #4CAF50, #2E7D32);
  --accent-sec: linear-gradient(135deg,#1976D2,#1565C0);
  --accent-tertiary: #4CAF50; /* для кнопок plants */
  --accent-food: linear-gradient(135deg,#FFB74D,#FF9800); /* для Калькулятора їжі */
  --muted-bg: #f4f4f4; /* додатковий фоновий відтінок */
}

/* ========== Body & general ========== */
body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 20px;
  transition: background 0.25s, color 0.25s;
  -webkit-font-smoothing: antialiased;
  text-align: center;
  padding: 0;
}

body.dark-theme {
  --bg: #121212;
  --text: #e6e6e6;
  --panel: #1f1f1f;
  --header-bg: #333;
}

/* ========== Layout helpers ========== */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

/* ========== Headings ========== */
h1 {
  margin-bottom: 18px;
  text-align: center;
}

/* ========== Controls / buttons ====== */
.controls {
  display: flex;              /* робимо флекс-контейнер */
  justify-content: center;    /* центруємо по горизонталі */
  align-items: center;        /* центруємо по вертикалі */
  flex-wrap: wrap;            /* якщо не влізають, переносяться на новий ряд */
  gap: 12px;                  /* відстань між кнопками */
  margin-bottom: 16px;
  position: relative;
  z-index: 10;                /* над накладками */
}

.controls .btn {
  display: flex;            /* flex всередині кнопки */
  align-items: center;      /* центруємо контент по вертикалі */
  justify-content: center;  /* центруємо контент по горизонталі */
  padding: 10px 20px;       /* внутрішні відступи */
  min-height: 44px;         /* мінімальна висота для мобільних */
  line-height: 1.2;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
  transition: transform 0.12s, background 0.12s;
}

/* Стилі для інших типів кнопок */
.btn.secondary { background: var(--accent-sec); }
.btn.tertiary { background: var(--accent-tertiary); color: #fff; }
button { border-radius: 6px; padding: 10px 20px; border: none; cursor: pointer; font-size: 14px; }

/* ====== Кнопка калькулятора їжі ====== */
.btn.quaternary,
.btn.food-calc {
  background: var(--accent-food);
  color: #1a1a1a;
  font-weight: 800;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  gap: 8px;
  box-shadow: 0 6px 18px rgba(255,165,0,0.12);
}

.btn.quaternary img,
.btn.food-calc img {
  width: 18px;
  height: 18px;
}

@media (hover: hover) {
  .btn.quaternary:hover,
  .btn.food-calc:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg,#ff9f1a,#ff7a00);
    color: #fff;
    box-shadow: 0 10px 26px rgba(255,120,0,0.18);
  }
}

/* Темна тема — кнопка калькулятора */
body.dark-theme .btn.quaternary,
body.dark-theme .btn.food-calc {
  background: linear-gradient(135deg,#ffb75a,#ff8a2b);
  color: #111;
}
body.dark-theme .btn.quaternary:hover,
body.dark-theme .btn.food-calc:hover {
  background: linear-gradient(135deg,#ff9f1a,#ff7a00);
  color: #fff;
}

/* Hover для інших кнопок */
.btn:hover,
button:hover { transform: translateY(-1px); background: #45a049; }

/* Темна тема для кнопок */
body.dark-theme .btn.tertiary,
body.dark-theme button { background: #2E7D32; color: #e6e6e6; }
body.dark-theme .btn.tertiary:hover,
body.dark-theme button:hover { background: #4CAF50; }

/* Темна тема для кнопки перемикання */
body.dark-theme #toggleTheme { background: #333; color: #e6e6e6; }
body.dark-theme #toggleTheme:hover { background: #555; }

/* ====== Забороняємо блокування натискання псевдо-фоном та GIF ====== */
body::before,
.bottom-gif,
.left-gif,
.right-gif { pointer-events: none; }

/* ========== Table common ========== */
table {
  margin: 12px auto 36px;
  border-collapse: collapse;
  width: 92%;
  max-width: 1100px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
  border-radius: 10px;
  overflow: hidden;
}

thead { background: var(--header-bg); }
body.dark-theme thead { background: rgba(255,255,255,0.04); }

th, td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 14px;
}
body.dark-theme th, body.dark-theme td { border-bottom-color: rgba(255,255,255,0.04); }

thead th { font-weight: 700; cursor: pointer; user-select: none; }
tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
body.dark-theme tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

th img { width:20px; height:20px; vertical-align:middle; }
td img { width:34px; height:34px; vertical-align:middle; margin-right:8px; }

/* ========== Recipes cards ========== */
.recipes {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  margin-bottom: 28px;
}

.recipe-tile {
  background-color: var(--panel);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 14px;
  width: 260px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  transition: transform .12s;
  text-align: left;
}
.recipe-tile:hover { transform: translateY(-4px); }
.recipe-tile h3 { text-align:center; margin-bottom:10px; }
.dish-image { text-align:center; margin-bottom:8px; }
.effects, .ingredients, .info, .note { margin-bottom:8px; font-size:14px; }
.ingredients img, .effects img, .info img { vertical-align: middle; margin-right:6px; cursor: default; }

/* ========== Plants specific ========== */
.scheme-container {
  display: none;
  margin-bottom: 30px;
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, 40px);
  grid-template-rows: repeat(6, 40px);
  gap: 2px;
  margin: 0 auto 20px;
  width: max-content;
}

.cell { width: 40px; height: 40px; border: 1px solid #ccc; }

.content { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; align-items: start; }

.card {
  background: var(--panel);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.card h3 {
  margin-top: 0;
  font-size: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
  margin-bottom: 10px;
}

.icons-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }

.icon {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
}

.icon img { width: 40px; height: 40px; object-fit: contain; }
.icon span { font-size: 12px; margin-top: 2px; }

.tooltip {
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  display: none;
}

.icon:hover .tooltip { display: block; }

/* ========== Harvest blocks (компактні та центровані) ========== */
.harvest-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 10px auto 15px auto;
  width: auto;
  max-width: fit-content;
}

.harvest-block .icons-row { justify-content: center; flex-wrap: wrap; margin-top: 5px; }

/* ========== Notes ========== */
.note {
  margin-top: 20px;
  padding: 15px;
  background: #eef9ee;
  border-left: 4px solid #4CAF50;
  border-radius: 6px;
  font-size: 14px;
}

/* ========== Character / Food Calculator styles ========== */
.character-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; margin-bottom: 20px; }

.character-card {
  width: 100px;
  background-color: var(--panel);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  box-sizing: border-box;
  border: 2px solid transparent;
}

.character-card:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 6px 15px rgba(0,0,0,0.25);
}

.character-card.selected {
  border-color: #007bff;
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  transform: scale(1.05);
}

.character-card img.character-icon { width: 60px; height: 60px; margin-bottom: 6px; transition: transform 0.2s; }
.character-card:hover img.character-icon { transform: rotate(-5deg) scale(1.05); }

.character-card .character-stats { display: flex; justify-content: center; gap: 4px; margin-bottom: 4px; }
.character-card .character-stats div { display: flex; flex-direction: column; align-items: center; font-size: 12px; background-color: transparent; }
.character-card .character-stats img { width: 25px; height: 25px; }

.character-card .character-name { font-weight: bold; font-size: 14px; margin-top: 4px; color: #333; transition: color 0.2s; }
.character-card:hover .character-name { color: #007bff; }

/* King of the Merms */
.king-button { width: 60px; height: 60px; border: none; background: none; padding: 0; cursor: pointer; display: none; position: relative; }
.king-button img { width: 50px; height: 50px; transition: transform 0.2s; }
.king-button:hover img { transform: scale(1.1); }
.king-button[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  opacity: 0.9;
}

/* Поточні показники */
.stats-inputs { display: flex; gap: 15px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat img { width: 40px; height: 40px; }
.stat input { width: 60px; margin-top: 4px; text-align: center; }

/* Кнопка розрахунку */
button#calculate {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  margin-bottom: 20px;
  border: none;
  border-radius: 6px;
  background-color: #007bff;
  color: #fff;
  transition: 0.2s;
}
button#calculate:hover { background-color: #0056b3; }

/* Результат */
#result {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 10px;
  background-color: #fefefe;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  max-width: 700px;
}
.food-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 80px;
  padding: 6px;
  border-radius: 8px;
  background-color: #fff;
  border: 1px solid #ddd;
  transition: transform 0.2s, box-shadow 0.2s;
}
.food-item:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.food-item img { width: 50px; height: 50px; border-radius: 6px; }
.food-item.negative { border-color: #f39c12; background-color: #fff3e0; }

/* Бейдж кількості */
.food-item .count-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: #007bff;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Показники їжі */
.food-stats { display: flex; gap: 4px; }
.food-stats div { display: flex; flex-direction: column; align-items: center; font-size: 12px; }
.food-stats img { width: 20px; height: 20px; }

/* Підсумок комбінації їжі */
.summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  width: 100%;
  max-width: 400px;
  background-color: #f9f9f9;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.summary-label {
  font-weight: bold;
  text-align: center;
  margin-top: 6px;
  margin-bottom: 2px;
  font-size: 14px;
  color: #333;
}
.summary .result-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 4px;
}
.summary .result-row div { display: flex; flex-direction: column; align-items: center; font-size: 14px; font-weight: bold; }
.summary .result-row img { width: 25px; height: 25px; margin-bottom: 2px; }

.reset-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background-color: #e74c3c;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  transition: 0.2s;
}
.reset-btn:hover { background-color: #c0392b; transform: scale(1.1); box-shadow: 0 5px 12px rgba(0,0,0,0.4); }
.reset-btn:active { transform: scale(0.95); box-shadow: 0 2px 6px rgba(0,0,0,0.3); }

/* Приховувати блок результату, коли порожній */
#result:empty { display: none; }

/* ========== Responsive ========== */
@media (max-width: 700px) {
  td, th { padding: 8px; font-size: 13px; }
  td img { width:28px; height:28px; }
  .recipe-tile { width: 100%; max-width: 420px; margin: 0 12px; }
  table { width: 98%; }
  .character-card { width: 80px; }
  .food-item { width: 70px; }
}
