/* ===== PRZYCISK KAWY ===== */
.coffee-btn {
  display: block;
  margin-top: 12px;
  line-height: 0;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s;
}

.coffee-btn:hover {
  opacity: 1;
  transform: scale(1.05);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #111;
  color: #ddd;
  font-family: Georgia, serif;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

h1 {
  color: #e0e0ff;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(200, 200, 255, 0.5);
}

/* ===== GAME CONTAINER ===== */
.game-container {
  background: #000;
  border: 3px solid #333;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

canvas {
  display: block;
  border-radius: 7px;
}

/* ===== FULLSCREEN ===== */
.game-container:fullscreen,
.game-container:-webkit-full-screen,
.game-container:-moz-full-screen,
.game-container:-ms-fullscreen {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #000 !important;
  width: 100vw !important;
  height: 100vh !important;
  border: none !important;
  border-radius: 0 !important;
  box-sizing: border-box !important;
  position: relative !important;
}

.game-container:fullscreen canvas,
.game-container:-webkit-full-screen canvas,
.game-container:-moz-full-screen canvas,
.game-container:-ms-fullscreen canvas {
  width: auto !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  display: block !important;
  position: static !important;
}

/* Overlaye (dialog, inventory, kod) muszą być nad canvas w fullscreen */
.game-container:fullscreen .dialog,
.game-container:-webkit-full-screen .dialog,
.game-container:fullscreen .inventory,
.game-container:-webkit-full-screen .inventory,
.game-container:fullscreen .code-input,
.game-container:-webkit-full-screen .code-input {
  position: fixed !important;
  z-index: 9999 !important;
}

.fullscreen-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  background: rgba(45, 55, 72, 0.8);
  border: 2px solid #4a5568;
  border-radius: 8px;
  cursor: pointer;
  z-index: 999;
  display: none; /* widoczny tylko w grze, nie w menu */
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  transition: all 0.3s ease;
  font-family: Arial, sans-serif;
}

.fullscreen-icon:hover {
  background: rgba(74, 85, 104, 0.9);
  border-color: #ed8936;
  transform: scale(1.1);
}

/* ===== UI / DEBUG ===== */
.ui {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 12px;
  color: #aaa;
}

.debug {
  margin-top: 20px;
  color: #666;
  font-size: 12px;
}

/* ===== INVENTORY ===== */
.inventory {
  position: absolute;
  top: 10px;
  right: 60px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #555;
  padding: 10px;
  border-radius: 5px;
  font-size: 12px;
  min-width: 140px;
  z-index: 998;
  display: none;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 4px;
  margin-top: 5px;
}

.inventory-slot {
  width: 32px;
  height: 32px;
  background: rgba(50, 50, 50, 0.8);
  border: 1px solid #666;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #ddd;
  transition: background 0.2s;
}

.inventory-slot:hover {
  background: rgba(70, 70, 70, 0.8);
  border-color: #888;
}

.inventory-slot.empty {
  opacity: 0.3;
  cursor: default;
}

/* ===== DIALOG ===== */
.dialog {
  position: absolute;
  bottom: 60px;
  left: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #555;
  padding: 15px;
  border-radius: 8px;
  display: none;
  font-size: 14px;
  z-index: 999;
  cursor: pointer; /* sygnalizuje klikalność */
}

/* Tooltip przy dialogu */
.dialog::after {
  content: "kliknij, aby zamknąć";
  position: absolute;
  bottom: -20px;
  right: 10px;
  font-size: 10px;
  color: #666;
  font-style: italic;
  pointer-events: none;
}

.dialog-option {
  background: rgba(100, 100, 100, 0.3);
  border: 1px solid #666;
  padding: 6px 10px;
  margin: 3px 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.dialog-option:hover {
  background: rgba(150, 150, 150, 0.4);
}

/* ===== CODE INPUT OVERLAY ===== */
.code-input {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  border: 3px solid #888;
  padding: 25px;
  border-radius: 10px;
  display: none;
  text-align: center;
  z-index: 10000;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

.code-input input {
  padding: 8px;
  font-size: 16px;
  background: #333;
  color: #ddd;
  border: 1px solid #666;
  border-radius: 4px;
  text-align: center;
  width: 100px;
  margin: 10px;
  letter-spacing: 4px;
}

.code-input button {
  padding: 8px 16px;
  margin: 5px;
  background: #555;
  color: #ddd;
  border: 1px solid #666;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.code-input button:hover {
  background: #666;
}

/* Canvas fullscreen */
canvas:fullscreen,
canvas:-webkit-full-screen,
canvas:-moz-full-screen,
canvas:-ms-fullscreen {
  width: auto !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  object-fit: contain;
  background: #000;
  display: block;
  margin: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ===== MOBILE OPTIMIZATION ===== */
@media (max-width: 820px) {
  body {
    padding: 8px;
    justify-content: flex-start;
    padding-top: 10px;
  }

  h1 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .game-container {
    width: 100%;
    max-width: 100vw;
    border-radius: 6px;
    border-width: 2px;
  }

  canvas {
    width: 100% !important;
    height: auto !important;
    border-radius: 4px;
    touch-action: none; /* zapobiega scrollowaniu podczas gry */
  }

  /* Ekwipunek na mobile - mniejszy */
  .inventory {
    right: 50px;
    top: 5px;
    padding: 6px;
    font-size: 10px;
    min-width: 110px;
  }

  .inventory-grid {
    grid-template-columns: repeat(3, 28px);
    gap: 3px;
  }

  .inventory-slot {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  /* Dialog na mobile - większy tekst, łatwiejszy do dotknięcia */
  .dialog {
    bottom: 5px;
    left: 5px;
    right: 5px;
    font-size: 13px;
    padding: 10px;
    max-height: 45vw;
    overflow-y: auto;
  }

  .dialog-option {
    padding: 10px 12px; /* większy obszar dotyku */
    margin: 4px 0;
    font-size: 13px;
  }

  /* Kod kłódki na mobile */
  .code-input {
    width: 90vw;
    padding: 20px;
  }

  .code-input input {
    font-size: 24px;
    width: 100px;
    padding: 10px;
  }

  .code-input button {
    padding: 12px 20px;
    font-size: 16px;
    min-height: 44px; /* min dotyk 44px */
  }

  /* Ikona fullscreen na mobile */
  .fullscreen-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    right: 5px;
    top: 5px;
  }

  /* Przycisk kawy na mobile */
  .coffee-btn img {
    width: 120px !important;
    height: auto !important;
  }

  /* UI copyright */
  .ui {
    font-size: 9px;
    bottom: 5px;
  }

  /* Debug info - ukryj na mobile */
  .debug {
    font-size: 10px;
    margin-top: 8px;
  }
}

/* Bardzo małe ekrany (iPhone SE itp.) */
@media (max-width: 380px) {
  h1 {
    font-size: 15px;
  }

  .dialog {
    font-size: 12px;
    padding: 8px;
  }

  .dialog-option {
    padding: 9px 10px;
    font-size: 12px;
  }
}

/* ===== MOBILE / RESPONSYWNOŚĆ ===== */
@media (max-width: 850px) {
  body {
    padding: 8px;
    justify-content: flex-start;
    padding-top: 10px;
  }

  h1 {
    font-size: 18px;
    margin-bottom: 8px;
  }

  .game-container {
    width: 100%;
    max-width: 100vw;
    border-radius: 6px;
    border-width: 2px;
  }

  canvas {
    width: 100% !important;
    height: auto !important;
    border-radius: 4px;
    touch-action: none;
  }

  /* Ekwipunek - większe sloty na dotyk */
  .inventory {
    right: 5px;
    top: 5px;
    padding: 6px;
    min-width: 110px;
  }

  .inventory-slot {
    width: 38px;
    height: 38px;
    font-size: 22px;
  }

  /* Dialog - większy tekst, łatwiejszy do kliknięcia */
  .dialog {
    bottom: 5px;
    left: 5px;
    right: 5px;
    font-size: 13px;
    padding: 12px;
    max-height: 45vw;
    overflow-y: auto;
  }

  .dialog-option {
    padding: 10px 12px;
    margin: 4px 0;
    font-size: 13px;
    min-height: 40px;
    display: flex;
    align-items: center;
  }

  /* Pole kodu - większe na telefonie */
  .code-input {
    width: 90vw;
    padding: 20px;
  }

  .code-input input {
    font-size: 24px;
    width: 100px;
    padding: 10px;
  }

  .code-input button {
    padding: 10px 20px;
    font-size: 15px;
    min-height: 44px;
  }

  /* Ikona fullscreen */
  .fullscreen-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  /* Przycisk kawy - schowany na małych ekranach */
  .coffee-btn {
    margin-top: 8px;
  }

  /* Debug info - ukryty */
  .debug {
    font-size: 10px;
  }
}

/* Bardzo małe ekrany (telefony do 400px) */
@media (max-width: 420px) {
  body {
    padding: 4px;
  }

  .inventory-grid {
    grid-template-columns: repeat(3, 36px);
    gap: 3px;
  }

  .inventory-slot {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .dialog {
    font-size: 12px;
    padding: 10px;
  }
}
