/* ===== Base ===== */
body {
  margin: 0;
  padding: 0;
  background-image: url("./images_dungeon/dungeon_bg.jpg");
  background-size: cover;
  background-repeat: repeat;
  background-position: center;
  min-height: 100vh;
  overflow: hidden;
}

#game-container {
  width: 100vw;
  height: 100vh;
  margin: 0 auto;

  display: flex;
  justify-content: flex-start;
  align-items: flex-start;

  overflow: auto;

  cursor: grab;
  user-select: none;

  scrollbar-width: none;
  -ms-overflow-style: none;
}

#game-container::-webkit-scrollbar {
  display: none;
}

#world {
  width: fit-content;
  height: fit-content;
  margin: auto;
}

#dungeon-canvas {
  display: block;
}

/* ===== Popup (Question) ===== */
#question-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;

  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 24px;
}

#question-overlay.hidden {
  display: none;
}

#question-modal {
  width: min(880px, 96vw);
  padding: 28px;
  border-radius: 20px;

  background: #161b22;
  color: #eef0f1;

  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);

  font-family: system-ui, -apple-system, sans-serif;
  transition: box-shadow 180ms ease, border-color 180ms ease,
    transform 180ms ease;
}

/* Neutral glow */
#question-modal:not(.is-correct):not(.is-wrong) {
  border-color: rgba(198, 138, 8, 0.5);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.95),
    0 0 30px rgba(230, 191, 107, 0.95), 0 0 80px rgba(222, 170, 57, 0.25);
}

/* Feedback states */
#question-modal.is-correct {
  border-color: #2ecc71;
  box-shadow: 0 0 40px rgba(46, 204, 113, 0.5);
}

#question-modal.is-wrong {
  border-color: #e74c3c;
  box-shadow: 0 0 40px rgba(231, 76, 60, 0.5);
}

#question-modal.is-shake {
  animation: modalShake 420ms ease;
}

#question-title {
  margin: 0 0 14px 0;
  color: #ffd700;
  font-size: clamp(16px, 2.5vw, 20px);
  letter-spacing: 1px;
  text-transform: none;
}

#question-text {
  margin: 0 0 25px 0;
  font-size: clamp(18px, 3vw, 28px);
  line-height: 1.35;
  color: #eef0f1;
  text-shadow: 2px 2px 4px #000;
  white-space: pre-line;
}

.question-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hidden {
  display: none !important;
}

#question-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin: 20px 0;
}

#question-actions button,
#close-question {
  padding: 18px 20px;
  border-radius: 8px;

  font-size: 20px;
  font-weight: 600;
  font-family: inherit;

  border: 2px solid #555;
  background: #3e3e3e;
  color: #e6edf3;

  cursor: pointer;
  transition: all 120ms ease;
}

#question-actions button:hover:not(:disabled) {
  background: #5a4d31;
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  transform: translateY(-2px);
}

#close-question {
  background: rgba(207, 146, 24, 0.2);
  color: #b7ac82;
  border-color: #c68a08;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}

#question-actions button.is-correct {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.2);
}

#question-actions button.is-wrong {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.2);
}

/* Ghost help button (pulse + glow) */
.ghost-help {
  margin-left: 12px;

  font-size: 26px;
  padding: 8px 12px;
  border-radius: 12px;

  border: 3px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);

  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;

  animation: ghostPulse 1.6s ease-in-out infinite;
}

.ghost-help:hover {
  transform: scale(1.08);
}

.ghost-help.hidden {
  animation: none;
}

@keyframes ghostPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(180, 255, 255, 0.25),
      0 0 10px rgba(180, 255, 255, 0.25);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(180, 255, 255, 0.08),
      0 0 22px rgba(180, 255, 255, 0.75), 0 0 40px rgba(150, 255, 255, 0.45);
    transform: scale(1.06);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(180, 255, 255, 0.25),
      0 0 10px rgba(180, 255, 255, 0.25);
    transform: scale(1);
  }
}

/* Pulse helper (league button) */
.pulse {
  animation: buttonPulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.6), 0 0 28px rgba(255, 215, 0, 0.35);
  border-color: #ffd700 !important;
}

@keyframes buttonPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes modalShake {
  0%,
  100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-8px);
  }
  36% {
    transform: translateX(8px);
  }
  54% {
    transform: translateX(-6px);
  }
  72% {
    transform: translateX(6px);
  }
  90% {
    transform: translateX(-3px);
  }
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9000;

  width: 90px;
  padding: 12px;
  border-radius: 18px;

  background: rgba(10, 12, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);

  backdrop-filter: blur(6px);
  color: #e6edf3;
  font-family: system-ui, -apple-system, sans-serif;

  text-align: center;
}

.hud-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 4px;
  margin-bottom: 10px;
}

.hud-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.75;
}

.hud-value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 20px;
}

.hud-time .hud-value {
  font-size: 20px;
  color: #ffd700;
}

.hud-inv {
  gap: 8px;
}

.inv-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.75;
  margin-bottom: 6px;
}

.inv-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  justify-items: center;
}

.inv-item {
  width: 46px;
  height: 46px;
  border-radius: 14px;

  display: grid;
  place-items: center;

  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);

  opacity: 0.2;
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}

.inv-item:hover {
  transform: scale(1.18);
}

.inv-item img {
  width: 28px;
  height: 28px;
  image-rendering: auto;
  filter: grayscale(1);
  opacity: 0.55;
  transition: filter 120ms ease, opacity 120ms ease;
}

.inv-emoji {
  font-size: 28px;
}

.inv-item.is-active {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.18);
}

.hud-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  justify-items: center;

  margin-top: 6px;
  margin-bottom: 0;
}

.hud-btn,
.hud-link {
  width: 46px;
  height: 46px;
  border-radius: 14px;

  display: grid;
  place-items: center;

  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e6edf3;
  text-decoration: none;

  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease,
    border-color 120ms ease;
}

.hud-btn:hover,
.hud-link:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 215, 0, 0.35);
}

/* ===== Start overlay ===== */
#start-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: flex;
  justify-content: center;

  /* felülről indul, görgethető */
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);

  padding: 24px;

  pointer-events: auto;
  touch-action: manipulation;
}

#start-overlay.hidden {
  display: none;
}

#start-modal {
  width: min(860px, 96vw);
  border-radius: 22px;
  padding: 28px;

  background: rgba(22, 27, 34, 0.92);
  border: 1px solid rgba(198, 138, 8, 0.45);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.75), 0 0 40px rgba(222, 170, 57, 0.22);

  color: #e6edf3;
  font-family: system-ui, -apple-system, sans-serif;

  pointer-events: auto;
  touch-action: manipulation;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

#start-title {
  margin: 0 40px 40px 0;
  color: #ffd700;
  letter-spacing: 2px;
  font-size: 22px;
}

.start-text {
  margin: 0 0 14px 0;
  font-size: 20px;
  line-height: 1.45;
  color: rgba(230, 237, 243, 0.92);
  text-shadow: 2px 2px 4px #000;
}

#start-btn {
  margin: 22px auto 0;
  padding: 16px 18px;
  border-radius: 12px;

  font-size: 18px;
  font-weight: 700;

  border: 2px solid #c68a08;
  background: rgba(207, 146, 24, 0.22);
  color: #ffd700;

  display: block;
  cursor: pointer;

  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

#start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
  background: rgba(207, 146, 24, 0.3);
}

#hud .inv-item.is-active {
  opacity: 1 !important;
}

#mobile-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: none;
  z-index: 1000;
  pointer-events: auto;
}

#mobile-controls button {
  width: 60px;
  height: 60px;
  font-size: 26px;
  margin: 4px;
  border-radius: 12px;
  border: none;
  background: rgba(20, 20, 20, 0.8);
  color: white;
  touch-action: manipulation;
}

@media (min-width: 780px) {
  #question-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 900px) {
  #mobile-controls {
    display: block;
  }

  #question-actions button,
  #close-question {
    font-size: 16px;
    padding: 12px 14px;
  }

  .start-text {
    font-size: 16px;
  }

  #start-title {
    font-size: 18px;
  }

  #start-btn {
    font-size: 16px;
    padding: 12px 14px;
  }

  /* ===== Mobile HUD drawer ===== */

  #hud {
    right: 14px;
    left: auto;
    bottom: 14px;
    top: auto;

    transform: none;

    width: 60px;
    max-height: 60vh;

    overflow: hidden;

    transition: all 0.25s ease;
  }

  /* összecsukott állapot */
  #hud.hud-collapsed {
    width: 70px;
    height: 46px;
    padding: 8px;

    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* csak az idő látszik */
  #hud.hud-collapsed .hud-row:not(.hud-time) {
    display: none;
  }

  #hud.hud-collapsed .hud-label {
    display: none;
  }
}
