/* FakeCraft UI - bez webfontů, aby to fungovalo i offline. */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0d12;
  color: #f2f2f2;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.4px;
  -webkit-font-smoothing: none;
  user-select: none;
  cursor: default;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.shadow, h1, h2, .btn, #hotbar-label, #debug, .hint {
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55);
}

/* ---------------------------- overlaye ---------------------------- */

#water-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(28, 78, 160, 0.55), rgba(12, 44, 110, 0.62));
  opacity: 0;
  transition: opacity 0.25s ease;
}
#water-overlay.on { opacity: 1; }

#damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(160, 0, 0, 0) 35%, rgba(150, 10, 10, 0.75) 100%);
  opacity: 0;
  transition: opacity 0.35s ease;
}
#damage-flash.on { opacity: 1; transition: opacity 0.05s ease; }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.38) 100%);
}

/* ------------------------------ HUD ------------------------------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
  mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #fff;
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }

#hearts {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(calc(-50% - 205px));
  display: flex;
  gap: 2px;
}
.heart {
  width: 18px;
  height: 18px;
  background: #4a1216;
  clip-path: polygon(25% 5%, 50% 22%, 75% 5%, 95% 28%, 50% 92%, 5% 28%);
}
.heart.full { background: #e33b3b; }
.heart.half {
  background: linear-gradient(90deg, #e33b3b 50%, #4a1216 50%);
}

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(20, 20, 24, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.55);
  border-radius: 3px;
}
.slot {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(70, 70, 78, 0.45);
  position: relative;
  image-rendering: pixelated;
}
.slot img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}
.slot.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.7);
  transform: scale(1.06);
}
.slot .num {
  position: absolute;
  right: 3px;
  bottom: 0;
  font-size: 13px;
  text-shadow: 1px 1px 0 #000;
}
.slot .dur {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 3px;
  background: rgba(0, 0, 0, 0.7);
}
.slot .dur i { display: block; height: 100%; background: #4fbe4f; }

#hotbar-label {
  position: absolute;
  left: 50%;
  bottom: 82px;
  transform: translateX(-50%);
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}
#hotbar-label.on { opacity: 1; transition: opacity 0.05s ease; }

#debug {
  position: absolute;
  left: 10px;
  top: 10px;
  font-size: 13px;
  line-height: 1.45;
  font-family: 'Consolas', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 9px;
  border-radius: 2px;
  white-space: pre;
}

#toast {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-shadow: 2px 2px 0 #000;
}
#toast.on { opacity: 1; transition: opacity 0.1s ease; }

/* ---------------------------- obrazovky --------------------------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 14, 0.55);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.screen[hidden] { display: none; }

#menu {
  background-color: #1a1a1f;
  background-size: 64px 64px;
  image-rendering: pixelated;
}
#menu::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.panel {
  position: relative;
  z-index: 2;
  min-width: 340px;
  max-width: 560px;
  padding: 26px 30px;
  background: rgba(18, 18, 22, 0.86);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  text-align: center;
  box-shadow: 0 14px 60px rgba(0, 0, 0, 0.6);
}

.logo {
  font-size: 46px;
  letter-spacing: 2px;
  color: #f4f4f4;
  text-shadow: 4px 4px 0 #2b2b2b, 0 0 26px rgba(120, 200, 120, 0.25);
}
.sub {
  font-size: 13px;
  opacity: 0.6;
  margin-bottom: 22px;
  font-weight: 400;
}
h2 { font-size: 24px; margin-bottom: 16px; }
h2.dead { color: #e05a5a; }

.buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}

.btn {
  font: inherit;
  font-size: 16px;
  padding: 11px 18px;
  color: #f2f2f2;
  background: linear-gradient(180deg, #7a7a7a, #5c5c5c);
  border: 2px solid #2b2b2b;
  border-radius: 2px;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.06s ease;
}
.btn:hover { filter: brightness(1.22); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn.danger { background: linear-gradient(180deg, #8c4a4a, #6b3535); }

.hint {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.62;
  margin-top: 10px;
  line-height: 1.5;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 12px 0;
  font-size: 14px;
  text-align: left;
}
.row input[type=range] {
  width: 100%;
  accent-color: #6fae52;
  cursor: pointer;
}

.bar {
  width: 300px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  margin: 12px auto 0;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6fae52, #a0d477);
  transition: width 0.2s ease;
}

/* --------------------------- inventář ----------------------------- */

.inv-panel {
  display: flex;
  gap: 22px;
  text-align: left;
  max-width: 900px;
  align-items: flex-start;
}
.inv-left { flex: 1 1 auto; }
.inv-right {
  flex: 0 0 250px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  padding-left: 18px;
  max-height: 62vh;
  overflow-y: auto;
}
.inv-panel h3 {
  font-size: 13px;
  opacity: 0.7;
  margin: 12px 0 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.craft-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}
.craft-row .arrow {
  font-size: 22px;
  opacity: 0.5;
  padding-bottom: 16px;
}

.cells {
  display: grid;
  gap: 3px;
}
.grid-2 { grid-template-columns: repeat(2, 44px); }
.grid-3 { grid-template-columns: repeat(3, 44px); }
#inv-main { display: grid; grid-template-columns: repeat(9, 44px); gap: 3px; }
#inv-hot { display: grid; grid-template-columns: repeat(9, 44px); gap: 3px; margin-bottom: 6px; }
#craft-grid { display: grid; gap: 3px; }
#craft-result { display: grid; grid-template-columns: 52px; }

.cell {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(64, 64, 72, 0.55);
  position: relative;
  cursor: pointer;
  image-rendering: pixelated;
}
#craft-result .cell {
  width: 52px;
  height: 52px;
  border-color: rgba(255, 235, 160, 0.5);
  background: rgba(90, 84, 60, 0.5);
}
.cell:hover { border-color: rgba(255, 255, 255, 0.65); background: rgba(96, 96, 104, 0.6); }
.cell img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.cell .count {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 12px;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
.cell .dur {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: 3px;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: none;
}
.cell .dur i { display: block; height: 100%; background: #4fbe4f; }

#cursor-stack {
  position: fixed;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 40;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
}
#cursor-stack img { width: 100%; height: 100%; image-rendering: pixelated; }
#cursor-stack .count {
  position: absolute;
  right: 0;
  bottom: -2px;
  font-size: 12px;
  text-shadow: 1px 1px 0 #000;
}

#tooltip {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  background: rgba(12, 12, 18, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 2px;
  white-space: nowrap;
}

.recipe {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
}
.recipe:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.06); }
.recipe.locked { opacity: 0.35; }
.recipe img { width: 28px; height: 28px; image-rendering: pixelated; }
.recipe b { font-size: 12px; display: block; }
.recipe small { opacity: 0.6; font-size: 11px; }

#hunger {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(calc(-50% + 210px));
  display: flex;
  gap: 2px;
}
.food {
  width: 17px;
  height: 17px;
  background: #3d2a12;
  clip-path: polygon(50% 0%, 78% 12%, 96% 42%, 78% 96%, 22% 96%, 4% 42%, 22% 12%);
}
.food.full { background: #c98a2e; }
.food.half { background: linear-gradient(90deg, #c98a2e 50%, #3d2a12 50%); }

@media (max-width: 900px) {
  .inv-right { display: none; }
}
@media (max-width: 640px) {
  .panel { min-width: auto; width: 92vw; padding: 20px 16px; }
  .slot { width: 40px; height: 40px; }
}
