/* Стилизация под классический GUI Minecraft (свои CSS-фаски, без текстур GUI) */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #2b2b2b;
  color: #333;
  font-family: Consolas, "Lucida Console", monospace;
  font-size: 14px;
  padding: 10px;
}

.mc-panel {
  background: #c6c6c6;
  border: 3px solid;
  border-color: #ffffff #555555 #555555 #ffffff;
  border-radius: 2px;
  padding: 10px;
}

header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
header h1 { font-size: 18px; color: #3f3f3f; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 42px; image-rendering: auto; }
.brand-sub { font-size: 11px; color: #5a6a5a; margin-top: 2px; }

footer {
  margin-top: 10px;
  text-align: center;
  font-size: 11.5px;
  color: #8a8a8a;
}
footer b { color: #b8c8b8; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.controls label { font-size: 12px; color: #3f3f3f; }

select, input[type=number], button, textarea {
  font-family: inherit;
  font-size: 13px;
  background: #8b8b8b;
  color: #fff;
  border: 2px solid;
  border-color: #373737 #ffffff #ffffff #373737;
  padding: 3px 8px;
}
button {
  background: #6f6f6f;
  border-color: #ffffff #373737 #373737 #ffffff;
  cursor: pointer;
}
button:hover { background: #7f8caf; }
button:active { border-color: #373737 #ffffff #ffffff #373737; }

main { display: flex; gap: 10px; align-items: flex-start; }

/* ---- палитра ---- */
#palette { width: 300px; flex-shrink: 0; max-height: 88vh; overflow-y: auto; }
#palette .hint { font-size: 11px; color: #5a5a5a; margin-bottom: 8px; }
#palette h3 {
  font-size: 12px; color: #404040; margin: 8px 0 4px;
  border-bottom: 1px solid #999;
}
.pal-grid { display: flex; flex-wrap: wrap; gap: 2px; }

.slot {
  width: 44px; height: 44px;
  background: #8b8b8b;
  border: 2px solid;
  border-color: #373737 #ffffff #ffffff #373737;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
}
.slot img {
  width: 36px; height: 36px;
  image-rendering: pixelated;
  pointer-events: none;
}
.slot.selected { outline: 3px solid #ffe94d; z-index: 2; }
.slot.broken { outline: 3px solid #ff3020; z-index: 2; }
.slot .fill {
  position: absolute; left: 0; bottom: 0; width: 100%;
  pointer-events: none; opacity: .55;
}
.slot .badge {
  position: absolute; right: 1px; bottom: 0;
  font-size: 11px; font-weight: bold; color: #fff;
  text-shadow: 1px 1px 0 #3f3f3f;
  pointer-events: none;
}

/* ---- сетка реактора ---- */
#board { flex-shrink: 0; }
#grid {
  display: grid;
  grid-template-columns: repeat(9, 48px);
  gap: 2px;
  background: #a0a0a0;
  padding: 6px;
  border: 2px solid;
  border-color: #555 #fff #fff #555;
}
#grid .slot { width: 48px; height: 48px; }
#grid .slot.disabled { background: #5b5b5b; cursor: not-allowed; }
#grid .slot.disabled img { display: none; }

#hull { margin-top: 10px; }
.hull-label { font-size: 12px; color: #404040; margin-bottom: 2px; }
.hull-bar {
  position: relative; height: 20px;
  background: #4c4c4c;
  border: 2px solid;
  border-color: #373737 #ffffff #ffffff #373737;
}
#hullFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #58c554, #e6c84c, #e0442e);
  transition: width .2s;
}
#hullText {
  position: absolute; inset: 0;
  text-align: center; line-height: 16px;
  color: #fff; font-size: 12px; text-shadow: 1px 1px 0 #333;
}
#status { margin-top: 8px; font-size: 13px; min-height: 20px; }
#status .ok { color: #1d7a1d; font-weight: bold; }
#status .warn { color: #a06000; font-weight: bold; }
#status .bad { color: #b01d10; font-weight: bold; }

/* ---- статистика ---- */
#stats { flex: 1; min-width: 320px; max-height: 88vh; overflow-y: auto; }
#stats h2 {
  font-size: 13px; color: #404040;
  margin: 6px 0 4px; border-bottom: 1px solid #999;
}
#stats table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#stats td { padding: 2px 4px; color: #3a3a3a; }
#stats td:last-child { text-align: right; font-weight: bold; color: #1f1f1f; }
#stats tr:nth-child(odd) { background: rgba(255,255,255,.25); }
#maint { font-size: 12px; color: #574000; margin-top: 6px; }
/* универсальное скрытие — класс hidden прячет любой элемент */
.hidden { display: none !important; }

#bomTitle.hidden { display: none; }
.bom-row {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: #3a3a3a; padding: 1px 4px;
}
.bom-row:nth-child(odd) { background: rgba(255,255,255,.25); }
.bom-row b { color: #1f1f1f; }
.bom-total { border-top: 1px solid #888; margin-top: 2px; color: #1d5a1d; }
.jrn-extra { width: 210px; }

/* ---- попап настроек и тултип ---- */
#popup {
  position: absolute; z-index: 10; padding: 8px; font-size: 12px;
}
#popup.hidden { display: none; }
#popup .dirs {
  display: grid; grid-template-columns: repeat(3, 30px);
  gap: 2px; margin: 6px 0; justify-content: center;
}
#popup .dirs button { padding: 2px; }
#popup .dirs button.on { background: #58c554; }

.tooltip {
  position: fixed; z-index: 100; /* поверх модалок */
  background: rgba(16, 0, 16, .95);
  border: 2px solid #25005f;
  color: #fff; font-size: 12px;
  padding: 6px 8px; pointer-events: none;
  max-width: 320px;
}
.tooltip .t-name { color: #ffe94d; margin-bottom: 3px; }
.tooltip .t-tier { color: #9c9c9c; font-size: 11px; }
.tooltip .t-guide {
  margin-top: 6px; padding-top: 5px;
  border-top: 1px solid #4a3a6a;
  color: #8fd47f; line-height: 1.35;
}
.tooltip .t-guide div + div { margin-top: 4px; }

/* ---- оптимизатор ---- */
button.accent { background: #4a7a3a; }
button.accent:hover { background: #58975a; }

#optModal {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
#optModal.hidden { display: none; }
.opt-box {
  width: 900px; max-height: 92vh; overflow-y: auto;
}
.opt-box h2 { font-size: 15px; color: #3f3f3f; margin-bottom: 8px; }
.opt-controls {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin-bottom: 6px; font-size: 12px; color: #3f3f3f;
}
.opt-presets button { padding: 2px 6px; font-size: 12px; }
.opt-box .hint { font-size: 11px; color: #5a5a5a; margin: 4px 0 8px; }

#optItems {
  display: flex; flex-wrap: wrap; gap: 3px;
  background: #b0b0b0; padding: 6px;
  border: 2px solid; border-color: #555 #fff #fff #555;
}
.opt-item {
  display: flex; align-items: center; gap: 2px;
  background: #9d9d9d; padding: 2px 4px 2px 2px;
  border: 1px solid #777;
  opacity: .45; cursor: pointer;
}
.opt-item.on { opacity: 1; background: #c9d7bd; }
.opt-item img { width: 24px; height: 24px; image-rendering: pixelated; }
.opt-item input {
  width: 44px; padding: 1px 3px; font-size: 11px;
}
.opt-run { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.opt-run .hidden { display: none; }
#optStop { background: #8a4a3a; }
#optStatus { font-size: 12px; color: #3f3f3f; flex: 1; }

#optResults { display: flex; gap: 10px; flex-wrap: wrap; }
.opt-result {
  background: #b8b8b8; border: 2px solid;
  border-color: #fff #555 #555 #fff;
  padding: 8px; width: 280px;
}
.opt-result .mini {
  display: grid; grid-template-columns: repeat(9, 26px); gap: 1px;
  background: #8b8b8b; padding: 3px; margin: 6px 0;
}
.opt-result .mini div {
  width: 26px; height: 26px; background: #a2a2a2;
  display: flex; align-items: center; justify-content: center;
}
.opt-result .mini img {
  width: 22px; height: 22px; image-rendering: pixelated;
}
.opt-result table { font-size: 11.5px; width: 100%; }
.opt-result td:last-child { text-align: right; font-weight: bold; }
.opt-result .ok { color: #1d7a1d; }
.opt-result .bad { color: #b01d10; }

/* ---- журнал топ-схем ---- */
#jrnModal {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
#jrnModal.hidden { display: none; }
.jrn-row {
  display: flex; gap: 10px; align-items: center;
  background: #b8b8b8; border: 1px solid #888;
  padding: 4px 8px; margin-bottom: 3px; font-size: 12.5px;
}
.jrn-place { font-weight: bold; width: 34px; color: #574000; }
.jrn-rod {
  width: 64px; display: flex; align-items: center; gap: 3px;
  font-size: 11px; color: #444;
}
.jrn-rod img { width: 20px; height: 20px; image-rendering: pixelated; }
.jrn-author { width: 120px; overflow: hidden; text-overflow: ellipsis;
              white-space: nowrap; font-weight: bold; }
.jrn-stat { flex: 1; }
.jrn-mark { width: 170px; color: #1d5a1d; }
.jrn-extra { width: 150px; color: #555; font-size: 11.5px; }
.jrn-row button { padding: 1px 6px; font-size: 11.5px; }
.jrn-filter { font-size: 12px; color: #3f3f3f; }
.jf-num { width: 64px; padding: 1px 4px; font-size: 12px; }

/* ---- модалка импорт/экспорт ---- */
#modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
#modal.hidden { display: none; }
.modal-box { width: 520px; }
.modal-box textarea { width: 100%; color: #fff; margin: 8px 0; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; }
